0

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

Apache
  • 1,796
  • 9
  • 50
  • 72

2 Answers2

0

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.

vindia
  • 1,678
  • 10
  • 14
0

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;  
    }           
   }  
Karuppiah RK
  • 3,894
  • 9
  • 40
  • 80
Apache
  • 1,796
  • 9
  • 50
  • 72