<!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=gb2312" />
<title>动态增加文本框</title>
<script type="text/javascript">
function xlh(){
document.getElementById("d1").appendChild(document.createElement("<input type='file'>"));
document.getElementById("d1").appendChild(document.createElement("<br />"));
}
</script>
</head><body>
<input type="button" id="btn" value="增加" onclick="xlh()" />
<div id="d1"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>动态增加文本框</title>
<script type="text/javascript">
function xlh(){
document.getElementById("d1").appendChild(document.createElement("<input type='file'>"));
document.getElementById("d1").appendChild(document.createElement("<br />"));
}
</script>
</head><body>
<input type="button" id="btn" value="增加" onclick="xlh()" />
<div id="d1"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>动态增加文本框</title>
<script type="text/javascript">
function xlh(){
try{
var file = document.createElement("input");
var br = document.createElement("br");
file.type = "file";
document.getElementById("d1").appendChild(file);
document.getElementById("d1").appendChild(br);
}
catch(e){alert(e)}
}
</script>
</head><body>
<input type="button" id="btn" value="增加" onclick="xlh()" />
<div id="d1"></div>
</body>
</html>
<Head>
<Script Language=JavaScript>
function insertRow(isTable){
index = isTable.rows.length;
nextRow = isTable.insertRow(index);
isText = nextRow.insertCell(0);
txtArea = nextRow.insertCell(1);
index++;
index = index.toString();
nameStr = "item"+index;
txtStr = "Item "+index;
isText.innerHTML = txtStr;
txtArea.innerHTML = "<input type=text name="+nameStr+" size=5><input type='button' value='删除附件' onclick='deleteRow("+index+")'>";
}
function deleteRow(index){
document.all.dynTable.deleteRow(index);
}</Script>
</Head>
<Body>
<Form name='Form1' action="1.asp">
<Table id='dynTable' cellpadding=5 cellspacing=5 border=1></Table>
<input type="submit" name="提交">
</Form>
<input type=button value="增加附件" onclick="insertRow(dynTable)" ></Body>
</HTML>
-------------------------------------------------
如果按照这个的话,增加好用,但是删除有问题,删除应该怎么改呢?