Search code examples
htmlcheckboxvalidationmultirow

to validate checkbox input for table using multiple rows


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


Solution

  • 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;  
        }           
       }