to validate checkbox input for table using multiple rows

1.1k Views Asked by At

i using js to add multiple row in a particular table, but when submit the form all check box having the same value, so how can i validate this checkbox using js before submit so change value to if unchecked, i trying on that but got no solution, does any one this before,

thanks in advance

2

There are 2 best solutions below

0
On BEST ANSWER

finally i found solution for my problem, thanks 'vindia' for the clue, i add checkbox with array, sol as below

in html

 `<input id="abc[]" name="abc[]" type="checkbox" value="1">`

in js

for(var i=0;i<chkDefaultLength;i++){  
   if(!document.neworupdateevent["chkDefault[]"][i].checked){  
        document.neworupdateevent["chkDefault[]"][i].value=0;  
    }           
   }  
0
On

What are your checkboxes called? Do they all have the same name? You have two options. One is giving each checkbox an unique name, the other is giving your checkbox a name like checkboxes[]. The [] lets all the values be entered into an array so they don't overwrite eachother.

If you mean something else, you have to state more clear what you want, because it's a bit incomprehensible right now.