我使用了一些Javascript来允许在页面上动态添加行。如何将此查询和下拉列表传递给动态创建的表格单元格?
用于动态添加单元格的Javascript:
<script language="javascript">
//add a new row to the table
var rownumber = 0;
function addRow()
{
rownumber++;
//add a row to the rows collection and get a reference to the newly added row
var newRow = document.all("tblGrid").insertRow();
//add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes
var oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t1' id=rownumber>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t2' id=rownumber>Test Client Input Row<input" +
" type='button' value='Delete' onclick='removeRow(this);'/>";
}
//deletes the specified row from the table
function removeRow(src)
{
/* src refers to the input button that was clicked.
to get a reference to the containing <tr> element,
get the parent of the parent (in this case <tr>)
*/
var oRow = src.parentElement.parentElement;
//once the row reference is obtained, delete it passing in its rowIndex
document.all("tblGrid").deleteRow(oRow.rowIndex);
}
</script>
查询和下拉列表代码:
<TR>
<TD><select name = "cno">
<option value=""></option>
<%
strSQL1 = "select cno, aliasname from Clients order by Aliasname asc"
Set rs1 = objConnection.Execute(strSQL1, ,adCmdText)
call ErrorHandler(err)
arr1 = rs1.GetRows()
for i = 0 to UBound(arr1,2)
cno = trim(arr1(0,i))
aliasname = trim(arr1(1,i))
%>
<option value = "<%=cno%>"><%=aliasname%></option>
<%
next
%>
</select></td></TR>
<TR>