i want to change the content of my div tag dynamically using javascript in PHP. I am using the following technqiue but it is not working.
<?php
echo "<script type='text/javascript'>\n";
echo "document.getElementById('mydiv').innerHTML = 'contents of div.......';";
echo "</script>";
?>
Plz guide me how can i do this
Thanks,
Best Regards,
Nice Candy.
embedding javascript in php
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: embedding javascript in php
Since there are no variables to expand in the code you showed above, there is no need to use PHP. You can put that script outside the <?php ?> tags.
(#10850)
Re: embedding javascript in php
And also make sure that the div with id ''mydiv" is actually fully loaded BEFORE the JS-snippet execution.