|
小类: <select name="Nclassid"> <%rs.open "select * from shop_news_nclass where anclassid="&selclass ,conn,1,1 if not(rs.eof and rs.bof) then %> <option selected value="<%=rs("NclassID")%>" ><%=rs("Nclass")%></option> <% rs.movenext do while not rs.eof%> <option value="<%=rs("NclassID")%>" ><%=rs("Nclass")%></option> <% rs.movenext loop end if rs.close set rs = nothing %> 最后我提供一个思路: <select name=txtclass ID=select3> <option value=1 <%if rs("txtclass")=1 then%>selected<%end if%>>普通用户</option> <option value=2 <%if rs("txtclass")=2 then%>selected<%end if%>>内部用户</option> <option value=3 <%if rs("txtclass")=3 then%>selected<%end if%>>vip用户</option> </select> 象以上的一个例子里是已知变量可能会有那几个值,作出判断是很容易的,但是在上一个例子里该怎么判断呢?这个应该是关键。 |
|
|
|
楼主不是已经在小类确定了第一个selected的了吗,还用得着判断后面的吗?
|
|
|
<option selected value="<%=rs("NclassID")%>" ><%=rs("Nclass")%></option>
==> <option <%if rs("NclassID")=selclass then %> selected <% end if %> value="<%=rs("NclassID")%>" ><%=rs("Nclass")%></option> |
|
|
错了,不好意思
你要把类的ID传过去,然后显示时判断一样就selected.方法如我上面那样 |
|
|
<select name="Nclassid">
<%rs.open "select * from shop_news_nclass where anclassid="&selclass ,conn,1,1 if not(rs.eof and rs.bof) then do while not rs.eof%> <option value="<%=rs("NclassID")%>" <%if rs("NclassID")=Request("NclassID") then %> selected <% end if %> ><%=rs("Nclass")%></option> <% rs.movenext loop end if rs.close set rs = nothing %> 结束 Request("NclassID") 你接受的新闻类数据ID |
|
|
刚才上面的那个方法试过了,不管用啊~
大家再帮忙想想办法吧,多谢了! |
|
|
还有那位老兄有解决的方案呢?谢谢!
|
|
|
怎么不管用?
你没有把类的ID传过去吧,一般都是按照我那个方法做的呀 |
|
|
在前面我先定义了rs1
<%dim rs1 set rs1=server.CreateObject("adodb.recordset") rs1.open "select * from shop_news where bookid="&bookid,conn,1,1 %> 后面改成这样 小类: <select name="Nclassid"> <%rs.open "select * from shop_news_nclass where anclassid="&selclass,conn,1,1 do while not rs.eof %> <option value="<%=rs("NclassID")%>" <%if rs("NclassID") = rs1("nclassid") then%> selected <% end if %> ><%=rs("Nclass")%></option> <% rs.movenext loop rs.close set rs = nothing %> 问题解决了! 呵呵 |
|
|
关键还是把RS1定义了,然后后面和RS里的nclassid进行比较
|
|
|
smart
|
|