问题
I've got a drop down list of customers. However, some of those customers get listed 2 or 3 times because they have multiple cities. What I would like to do is include the city in the same drop down list next to the city so that each entry is unique
<%
Dim DataConn
Dim custsel
Dim SQL
Set DataConn = Server.CreateObject("ADODB.Connection")
Set custsel = Server.CreateObject("ADODB.Recordset")
DataConn.Open "DSN=***;UID=***;PWD=***;"
SQL = "select custname, city FROM log.dbo.Customers order by CustName"
custsel.Open SQL, DataConn
%>
<table align="center" border="0">
<tr><th colspan="2"><b>Test Billing Transaction Summary</b></th></tr>
<tr><td colspan="2"><hr color="#ff7f26"></td></tr>
<tr><td width="50%" align="right">Customer Selection: </td>
<td width="50%" align="left">
<select name="custsel" id="custsel">
<% if Request.Form("custsel") = "All" then %>
<option value="All" selected>All</option>
<% else %>
<option value="All">All</option>
<% end if %>
<%While Not custsel.EOF%>
<option value="<%= custsel("custname") %>"><%= custsel("custname") %></option>
<%
custsel.MoveNext
Wend
custsel.Close
Set custsel = Nothing
DataConn.Close
Set DataConn = Nothing
%>
</select>
</td>
</tr>
<tr><td align="right">Summary Type: </td>
<td align="left"><select name="datetype" id="datetype">
<option value="">Date Type:</option>
<option value="LTD">Last Trade Day</option>
<option value="MtD">Month to Date</option>
<option value="YtD">Year to Date</option>
</select>
</td>
</tr>
<tr><td align="right">Start Date: <input value="" type="text" name="datepickstart" id="datepickstart" required></input></td>
<td align="left">End Date: <input value="" type="text" name="datepickend" id="datepickend" required></input></td>
</tr>
<tr><td colspan="2"><input type="submit" value="Execute" id="billingsubmit"></td></tr>
<tr><td colspan="2"><hr color="#ff7f26">
</td>
</tr>
</table>
回答1:
I changed the final line in my select box to:
<option value="<% =custsel("custname") %>" + "<% =custsel("city") %>"><% =custsel("custname") %> :<% =custsel("city") %></option>
However, I'd like to be able to call on the "CustName" and the "City" independently on the next page.
I'm currently calling the custname with:
<% dim custselect custselect = request.form("custsel") %>
Can I call on the city with:
<% dim cityselect cityselect = request.form("custsel") %>
来源:https://stackoverflow.com/questions/38379361/asp-drop-down-box-to-list-information-from-2-sql-server-columns