xjasonx Posted February 1, 2008 Share Posted February 1, 2008 Heres two parts of the code: echo "<script language=\"javascript\">"; echo "function openIt(x,y)"; echo "{"; echo "window.open(\"nwindow.php?id=arguments[0]&title=arguments[1]\",\"newwindow\",config=\"height=500,width=400\")"; echo "}"; echo "</script>"; "<a href=\"\" onClick=\"openIt($id,$title) \">Code</a></td>"; Then I get this error: Error: missing ) after argument list Source File: http://scriptsforgames.com/final_fantasy/scripts.php Line: 1, Column: 17 Source Code: openIt(1,Fishing V.1) Please help. I've tryed to fix this for so long. Quote Link to comment https://forums.phpfreaks.com/topic/88828-pass-php-variable-as-argument-in-javascript-function/ Share on other sites More sharing options...
kenrbnsn Posted February 1, 2008 Share Posted February 1, 2008 You need to surround the arguments with quotes, since they are strings. I'm assuming the string is part of an echo statement: <?php echo "<a href=\"\" onClick=\"openIt('$id','$title') \">Code</a></td>"; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/88828-pass-php-variable-as-argument-in-javascript-function/#findComment-454980 Share on other sites More sharing options...
xjasonx Posted February 1, 2008 Author Share Posted February 1, 2008 Wow, that was simple. So that got rid of the error, but now when I open the new window, it displays the variables as arguments[1]. echo "window.open(\"nwindow.php?id=arguments[0]&title=arguments[1]\",\"newwindow\",config=\"height=500,width=400\")"; Thanks a lot for the help. I won't be able to reply until tomorrow because I'm about to go to work. Quote Link to comment https://forums.phpfreaks.com/topic/88828-pass-php-variable-as-argument-in-javascript-function/#findComment-455011 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.