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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
LastTableID = 0;
function add() {
LastTableID = LastTableID + 1;
adTable = document.getElementById('atb_' + LastTableID);
if (adTable != null) {
adTable.style.display = "block";
}
else {
str = '<table id="atb_' + LastTableID + '" style="display:block">';
str = str + '<tr height="25" align=center valign=middle bgcolor=#FFFFFF>';
str = str + '<td><input type="text" name="input1_' + LastTableID + '"></td>';
str = str + '<td><input type="text" name="input2_' + LastTableID + '"></td>';
str = str + '<td><input type="text" name="input3_' + LastTableID + '"></td>';
str = str + '<td><input type="text" name="input4_' + LastTableID + '"></td>';
str = str + '</tr></table>';
window.upid.innerHTML += str + '';
}
}
function dellast() {
//alert(LastTableID);
if (LastTableID > 0) {
deleTable = document.getElementById('atb_' + LastTableID);
if (deleTable != null) {
deleTable.style.display = "none";
LastTableID = LastTableID - 1;
}
}
}
</script>
</head>
<body>
<form name="myform">
<table>
<tr>
<td>
<input name="Submit2" type="button" onclick="javascript:add()" value="增加">
<input type="button" name="del" onclick="javascript:dellast()" value="删除">
</td>
</tr>
<tr>
<td>
<div id="upid"></div>
</td>
</tr>
</table>
</form>
</body>
</html>
------解决方案--------------------
JScript code
LastTableID = 0;//全局变量
function add() //添加table方法
{
LastTableID = LastTableID + 1; //取得ID 全局变量LastTableID+1
adTable = document.getElementById('atb_' + LastTableID);//取得dom对象
if (adTable != null) {
adTable.st