How do you put a JS code in PHP?

The easiest solution would be to put the script block after the form. Another solution would be to capture the window.onload event or use the jQuery library (overkill if you only have this one JavaScript). Lately I’ve come across yet another way of putting JS code inside PHP code. It involves Heredoc PHP syntax.
For More Information Please Refer:
https://stackoverflow.com/questions/10596218/how-to-write-javascript-code-inside-php
You May Also Like to Read: