HTML获取input复选框多个值

<table>
  <tr><td><input type="checkbox" value="0" οnclick="allChoice()" id="allCheck" name="checks"> 全选td>tr>
  <tr><td>td>tr>
  <tr><td><input type="checkbox" value="三级报警" name="checks" οnclick="oneChoice()"> 三级报警td>tr>
  <tr><td>td>tr>
  <tr><td><input type="checkbox" value="二级报警" name="checks" οnclick="oneChoice()"> 二级报警td>tr>
  <tr><td>td>tr>
  <tr><td><input type="checkbox" value="一级报警" name="checks" οnclick="oneChoice()"> 一级报警td>tr>
  <tr><td>td>tr>
  <tr><td><input type="checkbox" value="车辆定位" name="checks" οnclick="oneChoice()"> 车辆定位td>tr>
  <tr><td>td>tr>
  <tr><td><input type="checkbox" value="车辆状态" name="checks" οnclick="oneChoice()"> 车辆状态td>tr>
  <tr><td>td>tr>
  <tr><td><input type="checkbox" value="车辆状况" name="checks" οnclick="oneChoice()"> 车辆状况td>tr>
table>

//下拉选复选框单选事件
function oneChoice(){
    var obj = $('[name="checks"]');
    check_val = [];
    for(k in obj){
        if(obj[k].checked && obj[k].value != "0")
            check_val.push(obj[k].value);
    }
    $("#sampling").val(check_val);
}

你可能感兴趣的:(javascript)