html table checkbox 多选取值

html

<dialog
style=”width:300px;height:1000px;border:solid 1px #000;position:absolute; text-align:center;z-index:99999999;”
>
<table id=”exTable” class=”table table-striped table-bordered table-hover” >
<thead>
<tr>

</tr>
</thead>
<tbody></tbody>
</table>

<p>你好呀!我是一个对话框!</p>
<button id=”close”>关闭</button>
<button id=”update_1″ onclick=”update_ex()”>更新</button>
</dialog>
<button id=”open” >打开</button>
<script>
var d = document.getElementsByTagName(“dialog”)[0],openD = document.getElementById(“open”),closeD = document.getElementById(“close”);
openD.onclick = function() {d.open=”open”;}
closeD.onclick = function() {d.open=””;}
</script>

js

function update_ex() {
var tbodyObj = document.getElementById(‘exTable’);
$(“table :checkbox”).each(function(key,value){
if($(value).prop(‘checked’)){
alert(tbodyObj.rows[key].cells[1].innerHTML);
alert(tbodyObj.rows[key].cells[2].innerHTML);
alert(tbodyObj.rows[key].cells[3].innerHTML);
}
})

function loaddataSQL(dataid) {

if(1==dataid){
var sqlStr = ‘select cexpresscocode as codea\,cexpressconame as namea from nw_expressco where s_mode=2 ;’;

JY.Model.loading();
$(“#show1”).empty();
$(“#exTable thead”).empty();
$(“#exTable tbody”).empty();
$(“#pageing ul”).empty();//清空分页
curType=””;//清空类型
curResult=0;//置为失败
JY.Ajax.doRequest(“baseForm”, jypath + ‘/backstage/nw/nwtradesubs/executeSQL’,{sqlStr : sqlStr}, function(data) {
var obj=data.obj,res=obj.res;
var information_html=””,resultList_html=””;
var lines=obj.lines,resMsg=obj.resMsg,rTime=obj.rTime,executesql=sqlStr;
if(JY.Object.notNull(obj.executesql)){
executesql=obj.executesql;
}

information_html+=”[SQL] “+executesql+”<br><br>”;

if(res==1){

information_html+=”受影响的行: “+lines+”<br>”;
information_html+=”响应时间: “+(rTime/1000)+”s<br>”;
var type=obj.type;
curType=type;

if(“query”==type){
var list=obj.list;
var results=list.results;
var thHtml =””,tbHtml=””;
var pageNum=list.pageNum,pageSize=list.pageSize,totalRecord=list.totalRecord;
if(results!=null&&results.length>0){
var leng=(pageNum-1)*pageSize;//计算序号
for(var i = 0;i<results.length;i++){
var datas=results[i];
if(i==0){

thHtml+=”<tr> <th class=’center’> <label><input type=’checkbox’ class=’ace’ ><span class=’lbl’></span></label> </th> <th style=’width:3%’ class=’center’>序号</th>”;
var wh=parseInt(97/datas.length);
for(var j = 0;j<datas.length;j++){

//$(“#ex_list”).append(‘<option value=”‘+datas[j]+'”></option>’);
thHtml+=”<th style=’width:”+wh+”%’ class=’center’ >”+datas[j]+”</th>”;
}
thHtml+=”</tr>”;
}else{
tbHtml+=”<tr>”;
tbHtml+=”<td class=’center’><label> <input type=’checkbox’ name=’ids1′ value='”+datas[j]+”‘ class=’ace’ /> <span class=’lbl’></span></label></td>”;
tbHtml+=”<td class=’center ‘>”+(i+leng)+”</td>”;
for(var j = 0;j<datas.length;j++){
//alert(datas[j]);
$(“#ex_list”).append(‘<option label=”‘+datas[j]+'” value=”‘+datas[j]+'”></option>’);
tbHtml+=”<td class=’center’>”+datas[j]+”</td>”;
}
tbHtml+=”</tr>”;
}
}
if(results.length==1){
tbHtml+=”<tr><td colspan=’30’ class=’center’>没有相关数据</td></tr>”;
}
$(“#exTable thead”).append(thHtml);
$(“#exTable tbody”).append(tbHtml);
JY.Page.setPage(“baseForm”,”pageing”,pageSize,pageNum,totalRecord,”executeSQL”);
}else{
tbHtml+=”<tr><td colspan=’30’ class=’center’>没有相关数据</td></tr>”;
$(“#exTable tbody”).append(tbHtml);
}
//查询激活
$(“#reslistLi a”).click();
curResult=1;
}else{
$(“#infoLi a”).click();
}
}else{
information_html+=”<font color=’red’>[Err] “+resMsg+”</font><br>”;
//查询激活
$(“#infoLi a”).click();
// $(“#show1 a”).click();

}
$(“#information”).html(information_html);
// $(“#show1”).html(information_html);
JY.Model.loadingClose();
});
}else{
JY.Model.info(“sql语句不能为空”);
}
}