Jump to content

String passing php to html and back


ameliabob

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...