我有以下代码,当我从下拉框中选择一个客户时,它将显示客户详细信息。这些详细信息来自查询result = request.querystring("result")
的SQL数据库,当我从下拉框中单击客户名称,并且页面将其详细信息加载到下拉列表中以保留其名称时,我想达到的目的。我已经尝试了几种组合,但如果可以的话,我似乎无法使其正常工作。
这是我目前所拥有的:
<select name="customers" onchange="location = this.value;">
<option value=""> Select... </option>
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connStr
strSQL = "SELECT DISTINCT fname, lname, cust_id FROM customer_details"
Set rs = conn.Execute(strSQL)
rs.movefirst
Do Until rs.eof or rs.bof
full_name = rs("fname") + " " + rs("lname")
response.write("<option value=""newdetails.asp?result=" & rs("cust_id") & """> " & full_name &" </option>")
rs.movenext
loop
rs.close
%>
</select>
其余代码,然后
<%
result = request.querystring("result")
%>
如果无法执行此操作,那么一旦加载详细信息,还有另一种方法可以使客户名称保持不变吗?
谢谢
只需添加...我已经在处理代码,并且我认为它已经起作用,但是如果有人可以告诉我这是否是正确的方法,我将不胜感激。
<%
result = request.querystring("result")
name = request.querystring("name")
If name = "" Then
name = "Please Select..."
End If
%>
<table class="alt">
<tr>
<td>Customer Name: </td>
<td>
<select name="customers" onchange="location = this.value;">
<option value="<%=name%>"> <%=name%> </option>
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connStr
strSQL = "SELECT DISTINCT fname, lname, cust_id FROM customer_details"
Set rs = conn.Execute(strSQL)
rs.movefirst
Do Until rs.eof or rs.bof
full_name = rs("fname") + " " + rs("lname")
response.write("<option value=""newdetails.asp?name=" & full_name & "&result=" & rs("cust_id") & """> " & full_name &" </option>")
rs.movenext
loop
rs.close
%>
</select>