Renegade85 Posted February 21, 2010 Share Posted February 21, 2010 Hi, I'm having problems creating a javascript function call using PHP I can't use ' around the string value $row[0] because it closes the javascript method call. print "<td><a href='javascript:addPlayer(" .$row[5] .",'" .$row[0] ."'," .$row[3] .")'>" .$row [0] . "</a></td> "; This code results in javascript:addPlayer(10, If I take out the single quote, I get this - javascript:addPlayer(10,Evra,7.8 ); //not including the space between 8 and ) The javascript method then fails because Evra is an undefined object :/ Anyone have any ideas how I could get around this? Link to comment https://forums.phpfreaks.com/topic/192773-apostrophe-problem/ Share on other sites More sharing options...
Renegade85 Posted February 21, 2010 Author Share Posted February 21, 2010 Was just thinking of other ways to code what I need. Using AJAX to get the player name value ($row[0]) would also work for me. I would rather use the original way of doing it though because it would be more efficient. If you can think of a way around my problem, please let me know or if you think there's no way around the problem, let me know too Link to comment https://forums.phpfreaks.com/topic/192773-apostrophe-problem/#findComment-1015489 Share on other sites More sharing options...
teamatomic Posted February 21, 2010 Share Posted February 21, 2010 I take it your problem lies in containing the href. Just use double quotes for it and escape them. "<a href=\"xxxxx\">"; HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/192773-apostrophe-problem/#findComment-1015519 Share on other sites More sharing options...
Renegade85 Posted February 21, 2010 Author Share Posted February 21, 2010 I take it your problem lies in containing the href. Just use double quotes for it and escape them. "<a href=\"xxxxx\">"; HTH Teamatomic That's done the job , thanks mate Didn't know you could do that lol Link to comment https://forums.phpfreaks.com/topic/192773-apostrophe-problem/#findComment-1015602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.