变量传进来后,如何让下拉框中对应变量的项目为默认选中?
我的代码如下:
<%
class2id=request( "class2id ")
%>
<select name= "class2id " onChange= "location.href= 'product_add2.asp?class2id= '+this.value ">
<%
set rsclass2=server.createobject( "adodb.recordset ")
sql= "select * from Class2 order by Class2Id desc "
rsclass2.open sql,conn,1,1,1
if not rsclass2.eof then
while not rsclass2.eof
%>
<option value= " <%=rsclass2( "Class2Id ")%> " <%if rsclass2( "class2id ")=class2id then response.write "selected "%> > <%=rsclass2( "Class2Name ")%>
</option>
<%rsclass2.movenext
wend
end if
rsclass2.close
set rsclass2=nothing
%>
</select>
现在选择下拉框中的某一项,页面刷新,经测试能够把该项的class2id传过来,但是 <%if rsclass2( "class2id ")=class2id then response.write "selected "%> 这里好像不起作用,把变量改成数字是有效果的,比如: <%if rsclass2( "class2id ")=180 then response.write "selected "%> , 请问为何?
------解决方案--------------------用
<%if rsclass2( "class2id ")=clng(class2id) then response.write "selected "%>