Improperly called Javascript function (parameter issue)

Posted by 13rave on Stack Overflow See other posts from Stack Overflow or by 13rave
Published on 2014-06-08T03:04:27Z Indexed on 2014/06/08 3:25 UTC
Read the original article Hit count: 68

Filed under:
|

I am trying to echo some HTML using PHP in a div. Everything was working until I tried to pass a parameter to the onclick=\"loadpuzzle()\" function. It ran fine when I tried onclick=\"loadpuzzle(4)\" and the function took the parameter and executed normally, but what I need is to pass the value from $row['puzzlename'] as the parameter, which I assume is a string (and so I enclosed it in quotation marks).

echo "<td><input id=\"".$row['puzzlename']."\" type=\"radio\" name=\"puzzle-set\"     class=\"puzzle_selector\"  onclick=\"loadpuzzle(\"".$row['puzzlename']."\")\"/>  
        <label for=\"".$row['puzzlename']."\" class=\"puzz_label\">".$row['puzzlename']."</label></td>";

I am getting a weird error in Safari when I try to run this. "Unexpected token: '}' ".

Does anyone know what I am doing wrong here? Why won't it take this parameter?

Thank you!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about php