get checked check boxes and store in array javascript

前端 未结 1 1141
失恋的感觉
失恋的感觉 2021-01-27 08:04

anyone can tell me how can i check and add checkbox checked values into an array?? get checked values on click and store in an array in javascript. This is my code.



        
相关标签:
1条回答
  • 2021-01-27 08:31

    Do you mean:

    
    var chkedVals = new Array; //array to store checked checkboxes value
    with(document.your_form_name) {
      for(var i = 0; i < checkbox.length; i++){
        if(checkbox[i].checked) {
           chkedVals.push(checkbox[i].value);
        }
      }
    }
    
    
    0 讨论(0)
提交回复
热议问题