jasonc Posted October 11, 2011 Share Posted October 11, 2011 I am trying to get a div's content to change using javascript but for some reason it is not working and i get no errors looking at the error console. the code that is waiting for the content... <div style="font-weight: bold;">count = <div id="desc" style="float: left;"></div> descriptions to do.</div><br clear="all" /> the code that should change the content.... <? echo("<script type=\"text/javascript\"> document.getElementById('desc').value='" . $count . "'; </script>"); ?> when i view the source code the javascript lines show like so... <script type="text/javascript"> document.getElementById('desc').value='373'; </script> do i have the javascript correct ? Link to comment https://forums.phpfreaks.com/topic/248880-unable-to-get-divs-content-to-change-using-javascript-and-divs-id/ Share on other sites More sharing options...
haku Posted October 11, 2011 Share Posted October 11, 2011 document.getElementById('desc').innerHTML=373; One point - you shouldn't be using a div for #desc, as it's not a division of your site. It's bad semantics. You should use a span tag instead. Link to comment https://forums.phpfreaks.com/topic/248880-unable-to-get-divs-content-to-change-using-javascript-and-divs-id/#findComment-1278165 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.