查询数据库以填充Javascript中的下拉列表?

查询数据库以填充Javascript中的下拉列表?,javascript,html,asp-classic,Javascript,Html,Asp Classic,我有一些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

我有一些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>

//向表中添加新行
var rownumber=0;
函数addRow()
{
行数++;
//向rows集合添加一行,并获取对新添加行的引用
var newRow=document.all(“tblGrid”).insertRow();
//向新行添加3个单元格(),并将innerHTML设置为包含文本框
var oCell=newRow.insertCell();
oCell.innerHTML=“”;
oCell=newRow.insertCell();
oCell.innerHTML=“测试客户端输入行”;
}
//从表中删除指定的行
函数删除程序(src)
{
/*src是指单击的输入按钮。
要获取对包含元素的引用,
获取父对象的父对象(在本例中)
*/   
var oRow=src.parentElement.parentElement;
//获得行引用后,通过其行索引将其删除
document.all(“tblGrid”).deleteRow(oRow.rowIndex);
}
查询和下拉列表代码:

<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>


您试图复制表中另一行的下拉列表?基本上,我想将相同的下拉列表插入ocell,但不确定如何在javascript中执行。基本上,您不能。由于ASP是一种服务器端语言,所以在将下拉列表发送到客户端之前,它将在服务器端得到渲染。因此,除了从页面上的现有元素复制它,或者创建一个服务服务器端返回一些JSON或XML,然后从服务返回的数据重新创建它之外,没有其他方法可以重建它;基本上阿贾克斯没有铃铛和哨子。