js获取checkbox值
程序员文章站
2022-05-31 13:40:37
...
1. 前端显示
2. 前段代码
<input type="checkbox" checked="checked" name="baseTable" value="product"/><span>product</span>
<input type="checkbox" checked="checked" name="baseTable" value="cmmprocess"/> <span>cmmprocess </span>
<input type="checkbox" checked="checked" name="baseTable" value="productparam"/> <span>productparam </span>
<div class="col-sm-4"><input type="checkbox" checked="checked" name="baseTable" value="app_user"/> <span>app_user </span>
<input type="checkbox" checked="checked" name="baseTable" value="equipinputaccount"/> <span>equipinputaccount </span>
<button type="button" class="btn btn-primary" onclick="Export()" style="margin-left:10px"> <i class="fa fa-download" aria-hidden="true"></i> 数据导出
</button>
3、js代码
function Export(){ //基础表导出
var obj = document.getElementsByName("baseTable");
var baseTable=[];
for(var i in obj){
if(obj[i].checked){
baseTable.push(obj[i].value);
}
}
alert(baseTable);
}