[color=blue]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>addUser.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/wpCalendar.js">
</script>
</head>
<body>
<div align="center">
<h1>
显示有的用户界面
</h1>
<div
style="border: 1px red solid; margin-bottom: 100px; padding: 10px 10%">
<table border="1px" cellpadding="0" cellspacing="0" id="tusers">
<thead>
<tr>
<th>
名称
</th>
<th>
性别
</th>
<th>
邮箱
</th>
<th>
出生日期
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody id="users">
</tbody>
</table>
</div>
<div style="border: 1px blue solid;">
<form>
<table>
<tr>
<td>
用户名:
</td>
<td>
<input type="text" name="name" id="name" />
</td>
</tr>
<tr>
<td>
性别:
</td>
<td>
<select id="sex">
<option value="男">
男
</option>
<option value="女">
女
</option>
</select>
</td>
</tr>
<tr>
<td>
邮箱:
</td>
<td>
<input type="text" name="email" id="email" />
</td>
</tr>
<tr>
<td>
出生日期:
</td>
<td>
<input type="text" id="bir" name="bir" />
<input type=button value="点击看我"
οnclick="showCalendar(this,document.all.bir)">
</td>
</tr>
<tr>
<td colspan="2" id="addu">
<input type="button" value="添加" οnclick="addUser()" />
</td>
</tr>
<tr id="addu1">
<td colspan="2">
<input type="button" value="修改" id="upduser" />
</td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
<script>
window.onload = function() {
document.getElementById("addu1").style.display="none";
}
function addUser() {
var name = document.getElementById("name").value;
var sex = document.getElementById("sex").value;
var email = document.getElementById("email").value;
var bir = document.getElementById("bir").value;
//获取表格节点对象
var tusers = document.getElementById("tusers");
//创建行
var tr1 = document.createElement("tr");
var tname = document.createElement("td");
var tsex = document.createElement("td");
var temail = document.createElement("td");
var tbir = document.createElement("td");
var toper = document.createElement("td");
var users = document.getElementById("users");
tname.appendChild(document.createTextNode(name));
tsex.appendChild(document.createTextNode(sex));
temail.appendChild(document.createTextNode(email));
tbir.appendChild(document.createTextNode(bir));
var adelete = document.createElement("a");
var aupdate = document.createElement("a");
adelete.setAttribute("href", "#");
aupdate.setAttribute("href", "#");
adelete.appendChild(document.createTextNode("删除"));
aupdate.appendChild(document.createTextNode("编辑"));
toper.appendChild(aupdate);
toper.appendChild(adelete);
//往行中添加
tr1.appendChild(tname);
tr1.appendChild(tsex);
tr1.appendChild(temail);
tr1.appendChild(tbir);
tr1.appendChild(toper);
users.appendChild(tr1);
tusers.appendChild(users);
adelete.onclick = function() {
var tda = adelete.parentNode;
var trb = tda.parentNode;
users.removeChild(trb);
}
aupdate.onclick = function() {
document.getElementById("addu").style.display = "none";
document.getElementById("addu1").style.display = "block";
var use = aupdate.parentNode.parentNode;
var uses = use.childNodes;
document.getElementById("name").value = uses[0].innerHTML;
document.getElementById("sex").value = uses[1].innerHTML;
document.getElementById("email").value = uses[2].innerHTML;
document.getElementById("bir").value = uses[3].innerHTML;
var upUser = document.getElementById("upduser");
upUser.onclick = function() {
use.childNodes[0].innerHTML = document.getElementById("name").value;
use.childNodes[1].innerHTML = document.getElementById("sex").value;
use.childNodes[2].innerHTML = document.getElementById("email").value
use.childNodes[3].innerHTML = document.getElementById("bir").value
document.getElementById("addu1").style.display = "none";
document.getElementById("addu").style.display = "block";
}
}
}
</script>[/color]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>addUser.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/wpCalendar.js">
</script>
</head>
<body>
<div align="center">
<h1>
显示有的用户界面
</h1>
<div
style="border: 1px red solid; margin-bottom: 100px; padding: 10px 10%">
<table border="1px" cellpadding="0" cellspacing="0" id="tusers">
<thead>
<tr>
<th>
名称
</th>
<th>
性别
</th>
<th>
邮箱
</th>
<th>
出生日期
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody id="users">
</tbody>
</table>
</div>
<div style="border: 1px blue solid;">
<form>
<table>
<tr>
<td>
用户名:
</td>
<td>
<input type="text" name="name" id="name" />
</td>
</tr>
<tr>
<td>
性别:
</td>
<td>
<select id="sex">
<option value="男">
男
</option>
<option value="女">
女
</option>
</select>
</td>
</tr>
<tr>
<td>
邮箱:
</td>
<td>
<input type="text" name="email" id="email" />
</td>
</tr>
<tr>
<td>
出生日期:
</td>
<td>
<input type="text" id="bir" name="bir" />
<input type=button value="点击看我"
οnclick="showCalendar(this,document.all.bir)">
</td>
</tr>
<tr>
<td colspan="2" id="addu">
<input type="button" value="添加" οnclick="addUser()" />
</td>
</tr>
<tr id="addu1">
<td colspan="2">
<input type="button" value="修改" id="upduser" />
</td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
<script>
window.onload = function() {
document.getElementById("addu1").style.display="none";
}
function addUser() {
var name = document.getElementById("name").value;
var sex = document.getElementById("sex").value;
var email = document.getElementById("email").value;
var bir = document.getElementById("bir").value;
//获取表格节点对象
var tusers = document.getElementById("tusers");
//创建行
var tr1 = document.createElement("tr");
var tname = document.createElement("td");
var tsex = document.createElement("td");
var temail = document.createElement("td");
var tbir = document.createElement("td");
var toper = document.createElement("td");
var users = document.getElementById("users");
tname.appendChild(document.createTextNode(name));
tsex.appendChild(document.createTextNode(sex));
temail.appendChild(document.createTextNode(email));
tbir.appendChild(document.createTextNode(bir));
var adelete = document.createElement("a");
var aupdate = document.createElement("a");
adelete.setAttribute("href", "#");
aupdate.setAttribute("href", "#");
adelete.appendChild(document.createTextNode("删除"));
aupdate.appendChild(document.createTextNode("编辑"));
toper.appendChild(aupdate);
toper.appendChild(adelete);
//往行中添加
tr1.appendChild(tname);
tr1.appendChild(tsex);
tr1.appendChild(temail);
tr1.appendChild(tbir);
tr1.appendChild(toper);
users.appendChild(tr1);
tusers.appendChild(users);
adelete.onclick = function() {
var tda = adelete.parentNode;
var trb = tda.parentNode;
users.removeChild(trb);
}
aupdate.onclick = function() {
document.getElementById("addu").style.display = "none";
document.getElementById("addu1").style.display = "block";
var use = aupdate.parentNode.parentNode;
var uses = use.childNodes;
document.getElementById("name").value = uses[0].innerHTML;
document.getElementById("sex").value = uses[1].innerHTML;
document.getElementById("email").value = uses[2].innerHTML;
document.getElementById("bir").value = uses[3].innerHTML;
var upUser = document.getElementById("upduser");
upUser.onclick = function() {
use.childNodes[0].innerHTML = document.getElementById("name").value;
use.childNodes[1].innerHTML = document.getElementById("sex").value;
use.childNodes[2].innerHTML = document.getElementById("email").value
use.childNodes[3].innerHTML = document.getElementById("bir").value
document.getElementById("addu1").style.display = "none";
document.getElementById("addu").style.display = "block";
}
}
}
</script>[/color]