ameliabob Posted August 11, 2011 Share Posted August 11, 2011 I am trying to build a function in the server to display on a browser which will allow the user to click on a checkbox and return values to the server. when I try using this code $p = "PickSignal('{".$r[direction]."}')"; $s .= "<td><input type='checkbox' onclick='".$p."'></td>"; I get a syntax error in firebug. Using firebug to look at the page I see this <table class="action" cellpadding="5"><tbody><tr><tr><td><input type="checkbox" {buy}')'="" onclick="PickSignal("></td> What am I missing? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 11, 2011 Share Posted August 11, 2011 It's a quote issue. This is what gets printed:<input type='checkbox' onclick='PickSignal('{buy}')'>Notice the single quotes mess up the onclick attribute. Link to comment Share on other sites More sharing options...
ameliabob Posted August 11, 2011 Author Share Posted August 11, 2011 It's a quote issue. This is what gets printed:<input type='checkbox' onclick='PickSignal('{buy}')'>Notice the single quotes mess up the onclick attribute.I am not sure I follow what you are saying here. To try and be more specific. I am trying to put the entire input line in an html document to send to a browser. So I would have the entire thing enclosed in double quotes. the word buy is the variable $r['direction'] after it has been interpreted. Wouldn't the single quotes chop this up? Link to comment Share on other sites More sharing options...
ShadowMage Posted August 11, 2011 Share Posted August 11, 2011 What jsg is saying is that you need to escape your quotes:$s .= "<td><input type='checkbox' onclick=\"".$p."\"></td>"; Link to comment Share on other sites More sharing options...
justsomeguy Posted August 11, 2011 Share Posted August 11, 2011 Look at the line, look at how the single quotes are set up:<input type='checkbox' onclick='PickSignal('{buy}')'>That's what the browser actually receives. Maybe you want it to get this instead:<input type='checkbox' onclick='PickSignal("{buy}")'>or this:<input type='checkbox' onclick="PickSignal('{buy}')"> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.