|
<HTML>
<head>
<title></title>
<script type="text/javascript">
function saveInfo(){
var tb = document.getElementById("tb");
var mytr = document.createElement("tr");
mytr.align = "center";
var mytd1 = document.create2Element("td");
var mytd2 = document.createElement("td");
var mytd3 = document.createElement("td");
var name = document.createTextNode(document.getElementById("username").value);
var pwd = document.createTextNode(document.getElementById("userpwd").value);
var del = document.createTextNode("刪除");
mytr.appendChild(mytd1);
mytr.appendChild(mytd2);
mytr.appendChild(mytd3);
mytd1.appendChild(name);
mytd2.appendChild(pwd);
var mya = document.createElement("A");
mya.href="#";
mya.onclick=deleteMe;
mya.appendChild(del);
mytd3.appendChild(mya);
tb.appendChild(mytr);
}
function deleteMe(){
var mytr = this.parentNode.parentNode;
confirm("您确定要删除"+ mytr.firstChild.firstChild.nodeValue +"吗");
mytr.parentNode.removeChild(mytr);
}
</script>
</head>
<body>
<table align="center" border="0">
<tr>
<td>用戶名:</td>
<td><input type="text" id="username" ></td>
<td><div id="errorname"></div></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" id="userpwd"></td>
<td><div id="errorpwd"></div></td>
</tr>
<tr>
<td colspan="3">
<input type="button" value="注册" onClick="saveInfo();">
<input type="reset" value="清除">
</td>
</tr>
</table>
<table align="center" border="1" style="border-collapse:collapse" id="tb">
<tr>
<td>用戶名</td>
<td>密码</td>
<td>cao作</td>
</tr>
</table>
</body>
</html>
欢迎来到Java學習者论坛,转载请注明地址:http://www.javaxxz.com. |
|