2021-05-27

Echo two separate javascript getElementById's from php

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?



from Recent Questions - Stack Overflow https://ift.tt/3wDGkpA
https://ift.tt/eA8V8J

No comments:

Post a Comment