-
效果如下
- 代码如下(后续完善加载动态table列表)
-
-
<html lang="en">
-
<head>
-
<meta charset="UTF-8">
-
<title>Title</title>
-
<script src="js/jquery-1.8.3.js"></script>
-
</head>
-
<body>
-
<table id="mytable" bgcolor="aqua" border="1" align="center"
-
style="top:20%;left:40%;position: absolute; 400px;height: 300px;">
-
<tr>
-
<td>姓名</td>
-
<td>是否男性</td>
-
</tr>
-
<tr>
-
<td>
-
<input id="col1" name="work" value="刘德华" style="height: 100%; 100%;"/>
-
</td>
-
<td>
-
<input type="radio" name="btn1" value="是">是
-
<input type="radio" name="btn1" value="否">否
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<input id="col2" name="work" value="林志玲" style="height: 100%; 100%;"/>
-
</td>
-
<td>
-
<input type="radio" name="btn2" value="是">是
-
<input type="radio" name="btn2" value="否">否
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<input id="col3" name="work" value="张飞" style="height: 100%; 100%;"/>
-
</td>
-
<td>
-
<input type="radio" name="btn3" value="是">是
-
<input type="radio" name="btn3" value="否">否
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<input id="col4" name="work" value="刘备" style="height: 100%; 100%;"/>
-
</td>
-
<td>
-
<input type="radio" name="btn4" value="是">是
-
<input type="radio" name="btn4" value="否">否
-
</td>
-
</tr>
-
</table>
-
<button onclick="onSubmit()" style="margin-left:50%;margin-top: 30%; 70px;height: 50px;">提交</button>
-
<script type="text/javascript">
-
function onSubmit() {
-
var ras3 = [];
-
var srTempNo, isMan;
-
var rows = document.getElementById("mytable").rows;
-
for (var i = 1; i < rows.length; i++) {
-
srTempNo = $("#col" + i).val();
-
isMan = $("input[name='btn" + i + "']:checked").val();
-
ras3.push({srTempNo: srTempNo, isMan: isMan});
-
}
-
alert("提交成功" + ":" + JSON.stringify(ras3));
-
}
-
</script>
-
</body>
-
</html>