View Full Version : Problem of commas in the string?

03-29-2007, 01:15 AM
Hi all.
I read data from DB and bind it with the onclick event of "carryvalue" function.
When the commas in the data string, my carryvalue function can't work. Is any method to avoid it without chaning my DB data string?

<script type="text/javascript">
function carryvalue(v01, v02){
document.getElementById('f02').value=v02; }


//some php code
echo' <tr onclick="carryvalue('."'".$record[$i][1]."','".$record[$i][2]."'".');"> ';
echo' <td class="c1">'.$record[$i][1]."</td> ";
echo' <td class="c2">'.$record[$i][2]."</td> ";
echo" </tr> ";
<form action="aa.php" OnSubmit="return isEmpty(this)" method="POST" name="myform">
<td class="mylabel" width="100">GroupID:</td>
<td><input type="text" name="VFGROUPID" size="80" id="f01" maxlength="8"></td>
<td class="mylabel" width="100">GroupName:</td>
<input type="text" name="VFGROUPNAME" size="80" id="f02" maxlength="30" />
<td colspan="2" style="text-align: center"><input type="reset" value="Reset">
<input type="submit" value="Save" name="FSAVE">
<input type="submit" value="Delete" name="FDEL"></td>

03-29-2007, 06:11 AM
Try the following code line

echo '<tr onclick="carryvalue(\''.$record[$i][1].'\',\''.$record[$i][2].'\');">';

03-29-2007, 09:05 AM
I try the code, but it seems not work ><"