John Davidson

Echo two separate javascript getElementById's from php

0 comments
Message:


I have PHP code that looks something like this which works fine on its own.


echo "<script type='text/javascript'>document.getElementById('flightTime3').innerHTML = </script>Dep: ";

However if I want to set the innerHTML of another element like so:


echo "<script type='text/javascript'>document.getElementById('flightDate3').innerHTML = </script>Arr: ";

The browser interperates it as setting the innerHTML of the first element only. So, the element with id flightTime3 shows "Dep: Arr: " and the element with id flightDate3 shows nothing.


How can I break up the javascript within the PHP so that it is recognised as two separate commands?



My Answer:
document.getElementById("element1");
document.getElementById("element2");

Rate this post

4 of 5 based on 6190 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us