例子一:
<script type="text/javascript">
var t = 1;
function addFile()
{
var parent = document.getElementById("more");
var br = document.createElement("br");
var input = document.createElement("input");
var button = document.createElement("input");
input.type = "file";
input.name = "uploadFile[" + (t++) + "].file";
input.size = "30";
button.type = "button";
button.value = "删除";
button.onclick = function()
{
parent.removeChild(br);
parent.removeChild(input);
parent.removeChild(button);
};
parent.appendChild(br);
parent.appendChild(input);
parent.appendChild(button);
}
</script>
例子二:
自动添加行js:
function addOneLineOnClick() {
var row=tblFlowCardDetail.insertRow(tblFlowCardDetail.rows.length);
var col = row.insertCell(0);
col.innerHTML = "<input readonly=\"true\" maxLength=6 size=6 name=aimId><input type=button value =... name=btnSelectAimClient index=\""+ rowIndex +"\" οnclick=\"selectAimClient(this.index)\">";
col = row.insertCell(1);
col.innerHTML = "<tr><input id=aimName name=aimName size=25 maxlength=25 readonly=\"true\">";
col = row.insertCell(2);
col.innerHTML = "<input readonly=\"true\" maxLength=6 size=6 name=itemNo><input type=button value =... name=btnSelectItem index=\""+ rowIndex +"\" οnclick=\"selectItem(this.index)\">";
col = row.insertCell(3);
col.innerHTML = "<input id=itemName name=itemName size=25 maxlength=25 readonly=\"true\">";
col = row.insertCell(4);
col.innerHTML = "<input id=spec name=spec size=10 maxlength=10 readonly=\"true\">";
col = row.insertCell(5);
col.innerHTML = "<input id=pattern name=pattern size=10 maxlength=10 readonly=\"true\">";
col = row.insertCell(6);
col.innerHTML = "<input id=unit name=unit size=4 maxlength=4 readonly=\"true\">";
col = row.insertCell(7);
col.innerHTML = "<input id=qty name=qty size=6 maxlength=6>";
col = row.insertCell(8);
col.innerHTML = "<input type='button' value='删除' id=btnDeleteLine name=btnDeleteLine οnclick=\"return DeleteRow('row" + rowIndex + "')\"></tr>";
rowIndex++;
}
<script type="text/javascript">
var t = 1;
function addFile()
{
var parent = document.getElementById("more");
var br = document.createElement("br");
var input = document.createElement("input");
var button = document.createElement("input");
input.type = "file";
input.name = "uploadFile[" + (t++) + "].file";
input.size = "30";
button.type = "button";
button.value = "删除";
button.onclick = function()
{
parent.removeChild(br);
parent.removeChild(input);
parent.removeChild(button);
};
parent.appendChild(br);
parent.appendChild(input);
parent.appendChild(button);
}
</script>
例子二:
自动添加行js:
function addOneLineOnClick() {
var row=tblFlowCardDetail.insertRow(tblFlowCardDetail.rows.length);
var col = row.insertCell(0);
col.innerHTML = "<input readonly=\"true\" maxLength=6 size=6 name=aimId><input type=button value =... name=btnSelectAimClient index=\""+ rowIndex +"\" οnclick=\"selectAimClient(this.index)\">";
col = row.insertCell(1);
col.innerHTML = "<tr><input id=aimName name=aimName size=25 maxlength=25 readonly=\"true\">";
col = row.insertCell(2);
col.innerHTML = "<input readonly=\"true\" maxLength=6 size=6 name=itemNo><input type=button value =... name=btnSelectItem index=\""+ rowIndex +"\" οnclick=\"selectItem(this.index)\">";
col = row.insertCell(3);
col.innerHTML = "<input id=itemName name=itemName size=25 maxlength=25 readonly=\"true\">";
col = row.insertCell(4);
col.innerHTML = "<input id=spec name=spec size=10 maxlength=10 readonly=\"true\">";
col = row.insertCell(5);
col.innerHTML = "<input id=pattern name=pattern size=10 maxlength=10 readonly=\"true\">";
col = row.insertCell(6);
col.innerHTML = "<input id=unit name=unit size=4 maxlength=4 readonly=\"true\">";
col = row.insertCell(7);
col.innerHTML = "<input id=qty name=qty size=6 maxlength=6>";
col = row.insertCell(8);
col.innerHTML = "<input type='button' value='删除' id=btnDeleteLine name=btnDeleteLine οnclick=\"return DeleteRow('row" + rowIndex + "')\"></tr>";
rowIndex++;
}