I have ‘n’ number of check box. The check box displays:
<?php
$result=mysql_query("select * from tablename where status='approved'");
$result1=$count=mysql_result(mysql_query("select max(id) from tablename where status='approved'"),0);
$limit=mysql_num_rows($result);
while($row=mysql_fetch_array($result)){?>
<input type="checkbox" name="chekgrp[]" id="cheks_<?php echo $row['id'];?>" onclick="Checkchk()" value="<?php echo $row['id'];?>" />
<?php }
?>
The value n is set in a hidden field
<input type ="hidden" value="<?php echo $limit; ?>" id="hiddenval" name=" hiddenval">
The javascript validation is:
var limits=parseInt(document.form.hiddenval.value);
var countelm=0;
for(i=1;i<= limits;i++){
if (("cheks_"+i).length>0){
if(document.getElementById("cheks_"+i).checked)
{
countelm = countelm +1;
}
}
}
It shows the above error if change the status to unapproved an element from table. I know it’s because I have changed the status of certain element. Is there any other way to check if element exists (checking length doesn't help) ? How to solve this error? Please help me.