PDA

View Full Version : Problem of commas in the string?



writeman
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('f01').value=v01;
document.getElementById('f02').value=v02; }
</script>

</head>
<body>


<?
//some php code
for($i=$start;$i<$end;$i++){
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">
<table>
<tr>
<td class="mylabel" width="100">GroupID:</td>
<td><input type="text" name="VFGROUPID" size="80" id="f01" maxlength="8"></td>
</tr>
<tr>
<td class="mylabel" width="100">GroupName:</td>
<td>
<input type="text" name="VFGROUPNAME" size="80" id="f02" maxlength="30" />
</td>
</tr>
<tr>
<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>
</tr>
</table>
</form>
</body>

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


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

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