farban6 Posted November 1, 2011 Share Posted November 1, 2011 Cant get it to work!! here is the code , how do i fix this? <script type="text/javascript"> function popup(var) { alert(var); } </script> <?php $calendar.= "<td class='calendar-day'><div style='position:relative;height:100px;' onclick='popup('hello')'>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/250257-quick-question-on-calling-js-function-inside-php-varible/ Share on other sites More sharing options...
xtopolis Posted November 1, 2011 Share Posted November 1, 2011 "var" is a reserved word in Javascript. The function itself should be surrounded by double quotes (escaped ones for your string). <script type="text/javascript"> function popup(v) { alert(v); } </script> <?php $calendar.= "<td class='calendar-day'><div style='position:relative;height:100px;border:1px solid black;' onclick=\"popup('hello')\">"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/250257-quick-question-on-calling-js-function-inside-php-varible/#findComment-1284112 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.