青岛市统计局官网:ASP程序问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/07 15:33:28
<select name="类别" size=1>

<%
String [] values = { "psychology", "business", "popular_comp" };

for (int i=0; i<values.Length; i++) {
%>

<option <% if (Request.QueryString["类别"] == values[i]) { Response.Write("selected"); } %>>
<%=values[i]%>
</option>

<% } %>

这个下拉框里面语句<option <% if (Request.QueryString["类别"] == values[i]) { Response.Write("selected"); } %>>这个是什么意思

for (int i=0; i<values.Length; i++) {
%>

<option <% if (Request.QueryString["类别"] == values[i]) { Response.Write("selected"); } %>>
<%=values[i]%>
</option>

<% } %>
for循环用来将:
"psychology", "business", "popular_comp"
添加到select(选择框)里

if语句是说,如果选择框选择了任意一个,就打印Selected,意思为该选择框已被选中

如果传递过来的"类别"参数=当前下拉项的值的话就选中它