Vbscript VBS-下拉列表每隔一行生成一个默认选项

Vbscript VBS-下拉列表每隔一行生成一个默认选项,vbscript,Vbscript,“我的VBS”下拉列表每隔一个列表显示一个选项“All” 我知道问题在我的期权价值中的某个地方,但我不确定如何解决这个问题,希望您能给予帮助 <% Dim DataConn Dim customersel Dim SQL Set DataConn = Server.CreateObject("ADODB.Connection") Set customersel = Server.CreateObject("ADODB.Recordset") %> <% DataConn.

“我的VBS”下拉列表每隔一个列表显示一个选项“All”

我知道问题在我的期权价值中的某个地方,但我不确定如何解决这个问题,希望您能给予帮助

<% 
Dim DataConn
Dim customersel
Dim SQL

Set DataConn = Server.CreateObject("ADODB.Connection")
Set customersel = Server.CreateObject("ADODB.Recordset")
%>

<%
DataConn.Open "DSN=***;UID=***;PWD=***"

SQL = "select customername FROM log.dbo.customer order by customerName"
customersel.Open SQL, DataConn
%>

<select Name="customersel" id="customersel">
<%While Not customersel.EOF%>
<% if Request.Form("customersel") = "0" then %>
<option value="0" selected>All
<% else %>
<option value="0">All
<% end if %>
<option value="<%= customersel("customername") %>"><%= customersel("customername") %></option>

<%
customersel.MoveNext
Wend

customersel.Close
Set customersel = Nothing
DataConn.Close
Set DataConn = Nothing
%>
</select>

全部的
全部的
特鲁多-费尔南德斯解决方案:

    <select Name="customersel" id="customersel">
    <% if Request.Form("customersel") = "0" then %>
    <option value="0" selected>All</option>
    <% else %>
    <option value="0">All</option>
    <% end if %>
    <%While Not customersel.EOF%>
    <option value="<%= customersel("customername") %>"><%= customersel("customername") %></option>

全部的
全部的

将if块移到循环外。。并确保关闭“全部”选项的选项标记。

将if条件移到循环之外(之前)。。你也没有把所有的选择权都投进去。非常感谢你。我认为这是很愚蠢的事情。我如何将你的回答标记为答案?不确定。。也许你会投票支持这个评论,或者我会添加一个答案:)再次感谢。我也把你的建议加在原稿上了。