问题一:
有一行表格,点击按钮后,再添加一行,以此类推,没有上限。(表格中含有文本域,此文本域有规律命名的,在提交列表单时,得要将这些添加进来的数据一一添加到数据库中)
问题二:
列表单添加成功后,怎么将此列表单(有可能会有多条记录)批量添加到数据库?
有一行表格,点击按钮后,再添加一行,以此类推,没有上限。(表格中含有文本域,此文本域有规律命名的,在提交列表单时,得要将这些添加进来的数据一一添加到数据库中)
问题二:
列表单添加成功后,怎么将此列表单(有可能会有多条记录)批量添加到数据库?
insertCell().innerHTML=""//单元格插入内容
jquery:
$("#table1").find("tr:last").clone(true).appendTo($(this));
应该加上清掉最后一行表格的内容
var temp=$("#table1").find("tr:last").clone(true);
temp.find("td").html("");
temp.appendTo($(this));
$(document).ready(function() {
$("#btnDelRow").attr("disabled", true);
$("#btnAddRow").click(function() {
$("#tabDetail tr:first").next("tr").clone().appendTo("#tabDetail");
$("#tabDetail tr:last td input").each(function() {
s = $(this).attr("name");
i = $("#tabDetail tr").length - 2;
$(this).attr("name", s + i);
});
$("#tabDetail tr:last td select").each(function() {
s = $(this).attr("name");
i = $("#tabDetail tr").length - 2;
$(this).attr("name", s + i);
});
$("#tabDetail tr:last td input").val("")
.focus(function() {
$(this).removeClass("text-input");
$(this).addClass("actived-text-input");
})
.blur(function() {
$(this).removeClass("actived-text-input");
$(this).addClass("text-input");
});
$("#btnDelRow").attr("disabled", false);
$("#tabDetail tr:last td input:first").focus("");
});
$("#btnDelRow").click(function() {
$("#tabDetail tr:last").remove();
$("#tabDetail tr:last td input:first").focus("");
$(this).attr("disabled", $("#tabDetail tr").length == 2);
});
});
</script>
<div style="float: right; marign 6px; marign-top: 4px; margin-bottom: 4px;">
<input type="button" id="btnAddRow" value="增加行" />
<input type="button" id="btnDelRow" value="删除行" />
</div>
<table id="tabDetail" style="width: 100%; margin-left: auto; margin-right: auto; margin-bottom: 4px; clear: both;">
<tr>
<th style="width: 160px; text-align: center"><a href="<?php echo dirname($_SERVER['SCRIPT_NAME']) . '/Return/Index/model.add' ?>">压缩机型号</a></th>
<th style="width: 120px; text-align: center">序列号</th>
<th style="width: 30px; text-align: center">数量</th>
<th style="width: 180px; text-align: center"><a href="<?php echo dirname($_SERVER['SCRIPT_NAME']) . '/Return/Index/issue.kind.add' ?>">失效模式</a></th>
<th style="text-align: center">失效描述</th>
</tr>
<tr>
<td>
<select id="cmbModel" name="cmbModel" style="width: 100%" required="true">
<?php
if (!empty($this->modelList)) {
foreach($this->modelList as $item) {
echo "<option family='" . $item["family"] . "' value='" . $item["modelName"] . "'>" . $item["modelName"] . "\n";
}
}
?>
</select>
<!--input type="text" id="edtModel" name="edtModel" required="true" tip="请输入压缩机型号" style="width: 99%" /-->
</td>
<td><input type="text" id="edtSeries" name="edtSeries" required="true" tip="请输入压缩机序列号" style="width: 99%" /></td>
<td><input type="text" id="edtQty" name="edtQty" required="true" tip="请输入数量" style="width: 96%" onKeypress="EnsureInt();" maxLength="4" value="1"/></td>
<td>
<select id="cmbIssueKind" name="cmbIssueKind" style="width: 100%" required="true">
<?php
if (!empty($this->issueKindList)) {
foreach($this->issueKindList as $item) {
echo "<option value='" . $item["issueKindId"] . "'>" . $item["issueKindName"] . "\n";
}
}
?>
</select>
</td>
<td><input type="text" id="edtIssueDesc" name="edtIssueDesc" required="true" tip="请输入失效描述" style="width: 99%" /></td>
</tr>
</table>