日期:2014-05-16 浏览次数:20381 次
<html> <head> <SCRIPT LANGUAGE="JavaScript"> function addRow() { var root = document.getElementById("tbody"); var allRows = root.getElementsByTagName('tr'); var cRow = allRows[0].cloneNode(true) root.appendChild(cRow); } function removeRow(r) { var root = r.parentNode; var allRows = root.getElementsByTagName('tr') if(allRows.length> 1) {root.removeChild(r);} else alert("only one row left, you can not remove it!"); } </SCRIPT> </head> <body > <table> <tbody id="tbody"> <tr> <td> <select name="s1"> <option>请</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <input name="s2"> <input type="button" value="Remove" onclick="removeRow(this.parentNode.parentNode)"> </td></tr> </tbody> <tr> <td> <input name="button" type="button" value="Add row" onclick="addRow()"> </td> </tr> </table> </body> </html>
------解决方案--------------------
[code=VBScript] <head><script language="JavaScript">
function addFile()
{
var str = '<br/><select name="select"></select><input type="text" name="textfield" />'
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str)
}
</script>
</head>
<body>
<p id="MyFile"><select name="select">
</select>
<input type="text" name="textfield" /></p>
<input type="button" value="增加文件" onclick="addFile()"/>
</body>code]