Page 1 of 1

string error

Posted: Sat Aug 19, 2006 1:39 am
by shiranwas
hi,,
what is the problam in this code, after i put the code for onClick event this gives me a error

can anyone help me

Code: Select all

$body="";

$body.= "<td height='5' ><input name='optSelected' type='radio' value='$count.$rows[1].' onclick='document.getElementById('result').innerHTML=this.value;' ></td>";
shiran

Posted: Sat Aug 19, 2006 1:42 am
by feyd
Check the nesting of your quotes and variables.

Posted: Sat Aug 19, 2006 1:46 am
by daedalus__
First tell us what your error is.

Try this:

Code: Select all

$body=""; 

$body.= '<td height="5" >
<input name="optSelected" type="radio" value="'.$count.'.'.$rows[1].'" onclick="document.getElementById(\'result\').innerHTML=this.value;" ></td>';
You really should use double quotes for HTML attributes. you do realise that when if you use single quotes for the onclick attribute, and then say (' that is is going to break out of the attribute. (at least it should)

I didn't understand this either..

Code: Select all

value='$count.$rows[1].'
Are you trying to concatenate those two variables? If you are, you will have to break out of the string.