hello i have been searching for some php code that is something like element.innerHTML in javascript but i can’t find it. i need it for some code that for example goes from 1-60 in 60 seconds
but if i do that with echo it just places everything under each other and that should not happen. i need something that just replaces the text. i also don’t want to reload my page every second and i don’t have the ability to write to files ( i can read them). and please don’t tell me that i should do it in javascript.
so can someone tell me how to do this?
hello i have been searching for some php code that is something like element.innerHTML
Share
You can use PHP to spit out javascript that does the replacing. There won’t be a pure PHP solution to this since PHP is server-side and doesn’t have access to the rendering of the page on the client side.
Suppose the text you need to change is in a
<div>tag named ‘replaceMe’. You will want to use the ob_flush() functions in PHP to force out the javascript at the time you need it to display. The PHP to initialize that isThen, each time you need to update, you have something like this in your PHP code that adds to the body of the page:
Of course if you want to make it easier for yourself, you can make a PHP function to print all this out given an argument containing the text to replace.
Then at the end you need to have