Using PHP value in javascript - working in alert() but not getelementbyid -


i using this:

$newpostid_fromcookie = $_cookie['scrolltobottom']+5000; echo "   <script>   window.onload = function () {     //document.getelementbyid('$newpostid_fromcookie').scrollintoview();     alert('$newpostid_fromcookie');   }   </script> "; 

this correctly shows value cookie in alert, getting 'is null' error when trying use value in getelementbyid.

how can use value in this?

your $newpostid_fromcookie seems integer. in xhtml, not valid , maybe browser not it. should use string (with prefix example):

document.getelementbyid('cookie_$newpostid_fromcookie').scrollintoview(); 

of course, change html in consequence.


Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -