Hi I have a check box when check that check box the id corresponding to the check box is placed on a text box ... but when there is only single value in the database i cant get the check value why? here is my code
<? if(isset($AcceptFriend)) {?>
<form action="<?=site_url()?>friends/Accept_Friend" name="orderform" id="orderform" method="post" style="background:#CCCC99">
<input type="text" name="chId" id="chId" >
<table border="0" height="50%" id="chkbox" width="50%" >
<tr>
<? foreach($AcceptFriend as $row)
{?>
<tr>
<td>Name</td><td><?=$row['dFrindName'].'</br>';?></td>
<td> <input type="checkbox" name="checkId" id="checkId" value="<? echo $row['dMemberId']; ?>" onClick="get_check_value()" ></td>
</tr>
<? }}?>
</tr>
<tr> <td width="10px"><input type="submit" name="submit" id="submit" class="buttn" value="AcceptFriend"></td></tr>
</table>
</form>
This is the script i am using
function get_check_value()
{
var c_value = "";
for (var i=0; i < document.orderform.checkId.length; i++)
{
if (document.orderform.checkId[i].checked)
{
c_value = c_value + document.orderform.checkId[i].value + "\n";
}
}
alert(c_value);
document.getElementById('chId').value= c_value;
}