millercj Posted December 7, 2008 Share Posted December 7, 2008 Hi everyone, i'm having an issue with executing a js command through php. The only problem as of now is that i'm trying to pass a variable which is a variable in my php script so I've done this: echo "<p>". $classes[$i][0]." - ".$classes[$i][1]." <a href='#' onclick='deleteclass(".$classes[$i][0].")'>delete</a></p>"; The variable gets correctly passed into the deleteclass() funtion but I still need quote around the variable for it to work. What is the correct syntax to make this work correctly? Quote Link to comment https://forums.phpfreaks.com/topic/135914-solved-passing-js-variable-in-php/ Share on other sites More sharing options...
gaza165 Posted December 7, 2008 Share Posted December 7, 2008 im confused, what do you need quotation marks around, the array $classes[$i][0] ???? are u passing a variable to the delete function?? Quote Link to comment https://forums.phpfreaks.com/topic/135914-solved-passing-js-variable-in-php/#findComment-708495 Share on other sites More sharing options...
millercj Posted December 7, 2008 Author Share Posted December 7, 2008 ok, what is currently happening is when the script is echoed back it ends up looking like this: <p><a href="#" onclick="deleteclass(4A)">delete</a></p> and I need to get quotes around the 4A so it'll execute...but I have all these quote in my php script but can't seem to get the right syntax Quote Link to comment https://forums.phpfreaks.com/topic/135914-solved-passing-js-variable-in-php/#findComment-708497 Share on other sites More sharing options...
.josh Posted December 7, 2008 Share Posted December 7, 2008 echo "<p>". $classes[$i][0]." - ".$classes[$i][1]." <a href='#' onclick='deleteclass(\"".$classes[$i][0]."\")'>delete</a></p>"; Quote Link to comment https://forums.phpfreaks.com/topic/135914-solved-passing-js-variable-in-php/#findComment-708498 Share on other sites More sharing options...
gaza165 Posted December 7, 2008 Share Posted December 7, 2008 Crayon is absolutly right!! Quote Link to comment https://forums.phpfreaks.com/topic/135914-solved-passing-js-variable-in-php/#findComment-708501 Share on other sites More sharing options...
millercj Posted December 7, 2008 Author Share Posted December 7, 2008 Sweet, thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/135914-solved-passing-js-variable-in-php/#findComment-708507 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.