ASP下拉框来列出来自2个SQL Server列的信息 [英] ASP drop down box to list information from 2 SQL Server columns
本文介绍了ASP下拉框来列出来自2个SQL Server列的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<%
Dim DataConn
Dim custsel
Dim SQL
Set DataConn = Server.CreateObject(ADODB.Connection)
Set custsel = Server .CreateObject(ADODB.Recordset)
DataConn.OpenDSN = ***; UID = ***; PWD = ***;
SQL =select custname,city FROM log.dbo.Customers order by CustName
custsel.Open SQL,DataConn
%>
< table align =centerborder =0>
< tr>< th colspan =2>< b>测试结算交易摘要< / b>< / th>< / tr>
< tr>< td colspan =2>< hr color =#ff7f26>< / td>< / tr>
< tr>< td width =50%align =right>客户选择:< / td>
< td width =50%align =left>
<%如果Request.Form(custsel)=全部,那么%>
< option value =Allselected>全部< / option>
<%else%>
< option value =All>全部< / option>
<%end if%>
<%while Notsel.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>摘要类型:< / td>
< td align =left>< select name =datetypeid =datetype>
< option value =>日期类型:< / option>
< option value =LTD>上一个交易日< / option>
< option value =MtD>月迄今< / option>
< option value =YtD>年迄今< / option>
< / select>
< / td>
< / tr>
< tr>< td align =right>开始日期:< input value =type =textname =datepickstartid =datepickstartrequired>< / input> < / TD>
< td align =left>结束日期:< / input>< / td>< input value =type =textname =datepickendid =datepickend ;
< / tr>
< tr>< td colspan =2>< input type =submitvalue =Executeid =billingsubmit>< / td>< / tr>
< tr>< td colspan =2>< hr color =#ff7f26>
< / td>
< / tr>
< / table>
解决方案
我将选择框中的最后一行更改为:
< option value =<%= custsel(custname)%> +<%= custsel(city)%>><%= custsel(custname)%> :<%= custsel(city)%>< / option>
但是,我希望能够调用CustName和City独立在下一页。
我目前正在调用custname:
<%dim custselect custselect = request.form(custsel)%>
我可以通过以下方式致电该城市:
<%dim cityselect cityselect = request.form(custsel)%>
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>
解决方案
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") %>
这篇关于ASP下拉框来列出来自2个SQL Server列的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文