jd2007 Posted August 7, 2007 Share Posted August 7, 2007 <?php echo "<script> function alert() { alert(document.getElementById('hello').value); } </script> <input id='hello' type='text' value='abc' onclick='alert();' />"; ?> Link to comment https://forums.phpfreaks.com/topic/63724-why-does-the-code-below-doesnt-work/ Share on other sites More sharing options...
xenophobia Posted August 8, 2007 Share Posted August 8, 2007 3 main problems: 1.) Your function name should not use "alert()". Is a reserved function name. 2.) Try put this in your script tag: <script language="JavaScript" type="text/javascript"> </script> Anyway, is a bad idea to use php to output some javascript. Try find some other way. Happy coding. Link to comment https://forums.phpfreaks.com/topic/63724-why-does-the-code-below-doesnt-work/#findComment-318550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.