Skip to content Skip to sidebar Skip to footer

Refresh Value On Page After Form Submit

So to simplify this considerably I'm not using my actual code but just trying to convey what I'm trying to do which is with a lot more data. let's say I have an external text file

Solution 1:

With the information you have provided to solve your issue, When the page submits you can retrive the data from the txt file again and show the it in the page. If you have a submit button it obviously refreshes the page. So there won't be an issue.

Solution 2:

PHP finishes doing its job once the page is loaded.

In your case, the new value will be displayed on the page ONLY after the page itself is refreshed. There is no way of changing the display without refreshing the page.

If you want to interactively change the value of the displayed text without refreshing the page itself, you will have to use Javascript.


...But if the displayed value isn't updated even after you submit (and is only updated after you hit refresh), there is a possibility that you are calling echo before you update the text file.

Solution 3:

It seems like you can already successfully update the file but cannot re-display that value on the page... once the page refreshes it should re-get the value and put the new value into your field. If you want to do that without refreshing you can do it with AJAX like this:

<scripttype="text/javascript">functionchangeText(){
        var newint = <?phpecho$data[0]; ?>;
    document.getElementById('newvalue').innerHTML = newint;
}
</script><pid='newvalue'></p><inputtype='button'onclick='changeText()'value='Change Text'/>

Post a Comment for "Refresh Value On Page After Form Submit"