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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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