<tr>
<td colspan="6">
<table class="table table-striped table-bordered table-hover" id="contenttable">
<thead align="center" style="font-weight: bold;">
<tr>
<td width="100px">设备类别</td>
<td width="150px">评价项目</td>
<td width="350px">验收细则</td>
<td width="200px">选项</td>
<td>说明</td>
</tr>
</thead>
<tbody id="esatable"></tbody>
</table>
</td>
</tr>
<tr>
<td colspan="6">
<select id="categorya" name="categorya" style="width: 200px" class="select" onchange="showtable()">
<option value="-1" selected>--其他设备类别--</option>
<option value="0">下拉单选项一</option>
<option value="1">下拉单选项二</option>
<option value="2">下拉单选项三</option>
<option value="3">下拉单选项四</option>
</select>
<table class="table table-striped table-bordered table-hover" id="esatablebshow">
<tbody id="esatableb"></tbody>
</table>
</td>
</tr>
//动态生成表1
function selectEsaInfo() {
var id = 1;
$.ajax({
type: "post",
url: "../esa/tableShow.cyl",
data: {
category_id : id
},
dataType: "json",
success: function(data){
var data = data.esaList;
var html = "";
html += "<tr><td rowspan='"+ data.length +"' align='center' >";
for (var i = 0; i < data.length; i++) {
html += ""+ data[i].esa_category+"</td>";
html += "<td align='center'>"+ data[i].esa_project +"</td>"
html += "<td>"+ data[i].esa_regulations +"</td>"
html += "<td align='center'>"
html += "<input type='radio' dc='facilities' di='"+ data[i].id +"' name='facilities"+ data[i].id +"' value='0'/>符合"
html += "<input type='radio' di='"+ data[i].id +"' name='facilities"+ data[i].id +"' value='1'/>不符合"
html += "<input type='radio' di='"+ data[i].id +"' name='facilities"+ data[i].id +"' value='2'/>不适用</td>"
html += "<td align='center'>"
html += "<textarea name='txa' dva='"+ data[i].id +"' style='border: none;width: 200px;height:40px;'></textarea>"
html += "</td></tr>"
}
$("#esatable").html(html);
mergeCell("esatable",1,data.length,0);
},
error: function(){
}
});
}
//动态生成表2
function showtable(){
var categorya = $("#categorya").val();
if (categorya == -1) {
return;
}
$.ajax({
type: "post",
url: "../esa/tableShow.cyl",
data: {
category_id : categorya
},
dataType: "json",
success: function(data){
var data = data.esaList;
var html = "";
html += "<tr><td rowspan='"+ data.length +"' align='center' width='100px'>";
for (var i = 0; i < data.length; i++) {
html += ""+ data[i].esa_category+"</td>";
html += "<td width='500px'>"+ data[i].esa_regulations +"</td>"
html += "<td align='center'>"
html += "<input type='radio' dc='machine' di='"+ data[i].id + "' name='machine"+ data[i].id +"' value='0'/>符合"
html += "<input type='radio' di='"+ data[i].id + "' name='machine"+ data[i].id +"' value='1'/>不符合"
html += "<input type='radio' di='"+ data[i].id + "' name='machine"+ data[i].id +"' value='2'/>不适用</td>"
html += "<td align='center'>"
html += "<textarea name='txs' dv='"+ data[i].id +"' style='border: none;width: 200px;height:40px;'></textarea></td>"
html += "</tr>"
}
$("#esatableb").html(html);
},
error: function(){
}
});
}
//取各表的rodio值与文本框值
function detmecSave() {
//获取第一个table里的rodio
var rds = $("input[dc='facilities']");
var option = {};
for (var i = 0; i < rds.length; i++) {
var id = rds[i].getAttribute("di");
var name = rds[i].getAttribute("name");
var value = $("input[name='" + name + "']:checked").val();
option[id] = (value == undefined ? null : value);
}
console.log(option);
//获取第一个table里的textarea
var textt = $("textarea[name='txa']");
var explaina = {};
for(var i = 0; i < textt.length; i++) {
var id = textt[i].getAttribute("dva");
var value = textt[i].value;
explaina[id] = value;
}
//console.log(explaina);
//获取第二个table里的rodio
var rdsa = $("input[dc='machine']");
var optiona = {};
for (var i = 0; i < rdsa.length; i++) {
var id = rdsa[i].getAttribute("di");
var name = rdsa[i].getAttribute("name");
var value = $("input[name='" + name + "']:checked").val();
optiona[id] = (value == undefined ? null : value);
}
console.log(optiona);
//获取第二个table里的textarea
var textts = $("textarea[name='txs']");
var tett = {};
for(var i = 0; i < textts.length; i++) {
var id = textts[i].getAttribute("dv");
var value = textts[i].value;
tett[id] = value;
}
//console.log(tett);
}