例子1:
<html>
<head>
<script lanuage="javascript">
var count=1;
function tt()
{
var obj = document.forms[0].getElementsByTagName("input");
if(count > 9 || obj[obj.length-1]
.value =="")
return alert("未选择上传文件或上传文件数已达到10个!");
var newRow = aa.insertRow().insertCell();
newRow.innerHTML += "<input type='file' name='url" + (++count) + "' size=20 class='txt'>";
}
</script>
</head>
<form>
<table id="aa" width="300" border="1" cellpadding="0" cellspacing="0"
borderColorLight="black" borderColorDark="white">
<tr><td>
<input type="file" name="url1" size="20">
</td></tr>
</table>
<button id="addButton"
onclick="tt();">继续添加文件选择框</button> <br/><br/>
<button
onclick="alert(document.forms[0].innerHTML);">显示表单HTML</button>
</form>
</html>
例子2:
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
var oTable = window.document.createElement("table");
oTable.border = 1;
var oTR = oTable.insertRow();
var oTD = oTR.insertCell();
oTD.innerText = "1.1";
oTD = oTR.insertCell();
oTD.rowSpan = 2;
oTD.innerText = "1.2/2.2";
oTR = oTable.insertRow();
oTD = oTR.insertCell();
oTD.innerText = "2.1";
document.body.appendChild(oTable);
//-->
</SCRIPT>
</body>
转载于:https://www.cnblogs.com/ufo0303/archive/2006/08/18/480333.html