例子1:(具体参照drp中的flow_card_add.jsp)
<script>
var rowIndex = 0;
function addOneLineOnClick() {
var row=tblFlowCardDetail.insertRow(tblFlowCardDetail.rows.length);
var col = row.insertCell(0);
col.innerHTML = "<input type="hidden" name="aimInnerId" id="aimInnerId"><input type=button value =... name=btnSelectAimClient index=""+ rowIndex +"" >";
col = row.insertCell(1);
col.innerHTML = "<input id=aimName name=aimName size=25 maxlength=25 readonly="true">";
col = row.insertCell(2);
col.innerHTML = "<input type='button' value='删除' id=btnDeleteLine name=btnDeleteLine onclick="return DeleteRow('row" + rowIndex + "')">";
row.setAttribute("id", "row" + rowIndex);
rowIndex++;
}
function DeleteRow(rowTag){
var i = tblFlowCardDetail.rows(rowTag).rowIndex;
var j;
for(j=i;j<=rowIndex;j++) {
tblFlowCardDetail.rows(j).cells(0).all("btnSelectAimClient").index--;
tblFlowCardDetail.rows(j).cells(2).all("btnSelectItem").index--;
}
tblFlowCardDetail.deleteRow(i);
rowIndex--;
}
</script>
<body>
<table>
<tr>
<td>cell0</td>
<td>cell1</td>
<td>cell2</td>
</tr>
</table>
<input name="btnAddLine" type="button" id="btnAddLine" onClick="return addOneLineOnClick()" value="加入一行">
</body>
例子2:
<body>
<form action="<%=path %>/news.do?method=add" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="${news.id }">
<table width="90%" border="0" align="left" cellpadding="0" cellspacing="1" class="newTable">
<tr>
<td class="newTd">新闻标题</td>
<td class="newTd"><input type="text" name="title" size="30"></td>
</tr>
<tr>
<td class="newTd">新闻副标题</td>
<td class="newTd"><input type="text" name="subTitle" size="30"></td>
</tr>
<tr>
<td class="newTd">新闻内容</td>
<td class="newTd"><textarea class="ckeditor" name="content"></textarea></td>
</tr>
<tr>
<td class="newTd">新闻图片</td>
<td class="newTd" id="more"><input type="file" name="uploadFile[0].file" size="30"><input type="button" onclick="addFile();" value="增加"></td>
</tr>
<tr>
<td class="newTd">新闻所属板块</td>
<td class="newTd">
<select id="modelSelect" name="modelId">
</select>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="保存">
<input type="reset" value="重置">
</td>
</tr>
</table>
</form>
<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>
</body>