<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name=test>
<SCRIPT LANGUAGE=javascript>
<!--
//定义一个数组
var arrTable=new Array();
var index=0;
//定义添加行的函数
function addRows(){
if (test.col1.value=="" || test.col2.value==""){
return false;
}else{
arrTable[index]=new Array();
arrTable[index][0]=test.col1.value;
arrTable[index][1]=test.col2.value;
reDrawTable();
index++;}
}
function UpdateRows(iIndex,iSerial,strValue)
{
//window.confirm(iIndex+":"+iSerial+":"+strValue);
arrTable[index]=new Array();
arrTable[iIndex][iSerial]=strValue;
}
//定义重画表单函数
function reDrawTable(){
var textTable="<table>";
for (i=0;i<arrTable.length;i++){
textTable+="<tr>";
textTable+="<td><input type=text name=TESTA value='"+arrTable[i][0]+"' onchange='UpdateRows("+i+",0,this.value)'></td>";
textTable+="<td><input type=text name=TESTB value='"+arrTable[i][1]+"' onchange='UpdateRows("+i+",1,this.value)'></td>";
textTable+="</tr>";
}
textTable+="<tr>";
textTable+="<td><input type=text name=col1 value=''></td>";
textTable+="<td><input type=text name=col2  value=''></td>";
textTable+="</tr>";
textTable+="</table>";
testTable.innerHTML=textTable;
}
//-->
</SCRIPT><div id="testTable">
<table>
<tr>
<td><input type=text ID=col1 value=''></td>
<td><input type=text ID=col2 value='' ></td>
</tr>
</table>
</div>
<input type="button" value="增加数据" onclick="addRows()">
</form>
</BODY>
</HTML>