<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
//add a new line
var n=1,fn,temp;
function addline()
{
n++;
newline=document.all.test.insertRow();
newline.insertCell().innerHTML=n+'>';
newline.insertCell().innerHTML='<input type="text" name=f'+n+' id=f'+n+' size="20">'+'<input name="fd"'+n+' type="button" value="." onClick=openScript("test.html","pur",390,270) >';
newline.insertCell().innerHTML='<input type="text" name=p'+n+' id=p'+n+' size="20">';
newline.insertCell().innerHTML='<a href=javascript:void(0) οnclick=delline('+n+')>D</a>';
}
//open a new window
function openScript(url,name, width, height)
{
var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
//delete a line
function delline(i){
if(i==n){
document.all.test.deleteRow(window.event.srcElement.parentElement.parentElement.rowIndex);
n=n-1;
}
else
alert("请选择删除最后一条记录");
}
//view the values input
function returnShow(){
var myArray = new Array(n);
for (var i=0; i < n; i++)
{
//coluns of line
myArray[i] = new Array(2);
myArray[i][0] = document.all["f"+(i+1)].value;
myArray[i][1] = document.all["p"+(i+1)].value;
if(i==0)
fn="n="+n+"&name"+(i+1)+"="+myArray[i][0]+"&"+"pass"+(i+1)+"="+myArray[i][1];
else if(i==(n-1)||i>0)
fn=fn+"&name"+(i+1)+"="+myArray[i][0]+"&"+"pass"+(i+1)+"="+myArray[i][1];
else
fn=fn+"&name"+(i+1)+"="+myArray[i][0]+"&"+"pass"+(i+1)+"="+myArray[i][1];
}
alert(fn);//we can insert hypelink here to insert recordinto database
}
</script>
</head>
<body>
<form method="post" name="form1" >
<table width="44%" border="1" cellpadding="0" cellspacing="0" id="test" bordercolor="#0066ff">
<tr>
<td width="2%"><script language="javascript">document.write(n);</script>></td>
<td width="41%">
<input type='text' name="f1" id="f1" size='20'><input name="btn_txt_TF_POS_PRD_NAME" type="button" id="btn_txt_TF_POS_PRD_NAME2" value="." onClick="openScript('test.html','pur',390,270)">
</td><td width="46%">
<input type='text' name="p1" id="p1"size='20'></td><td width="11%"></td></tr>
</table>
<input type="button" onClick="addline()" name="Submit" value="Add">
<input type="button" onClick="javascript:returnShow();" name="show" value="show">
</form>
</body>
</html>