<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="动态添加删除.aspx.cs" Inherits="JavaScript练习.动态添加删除" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function loadData() {
var table = document.getElementById("table");
var data = { "字段0": "<input type='checkbox' name='checkbox'/>", "字段一": "<input type='text' id='txtItem1' ruant='server'/>", "字段2": "<input type='text' id='txtItem2' ruant='server'/>", "字段3": "<input type='text' id='OrderNum' ruant='server'/>" };
var tr = document.createElement("tr");
for (var key in data) {
var value = data[key];
var td1 = document.createElement("td");
td1.innerText = key;
tr.appendChild(td1);
var td2 = document.createElement("td");
td2.innerHTML = value;
tr.appendChild(td2);
table.tBodies[0].appendChild(tr);
}
}
function loadDelete() {
var checkAll = document.getElementsByName("checkbox");
for (var i = 0; i < checkAll.length; i++) {
if (checkAll[i].checked == true) {
var table = document.getElementById("table");
table.tBodies[0].removeChild(table.rows[i])
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="table">
<tbody>
</tbody>
</table>
<input type="button" value="动态增加" onclick="loadData()" id="btnCreate" runat="server"/>
<input type="button" value="动态删除" onclick="loadDelete()" />
</div>
</form>
</body>
</html>
我的目的是动态增加删除行,并在动态增加按钮写onserverclick="btnCreate_ServerClick1",为什么加了onserverclick="btnCreate_ServerClick1"就不能增加行了
谁能帮我解决谢谢