07-12
20
关于ASP中使用session
作者:Java伴侣 日期:2007-12-20
每次提交后将取得的用户选择的值保存在SESSION中:
下拉列表改成下面这样:
复制内容到剪贴板 程序代码
Session("Nclassid") = Trim(Request.Form("Nclassid"))
下拉列表改成下面这样:
复制内容到剪贴板 程序代码
<select name="Nclassid" onChange="changelocation2(document.yuziform.Nclassid.options[document.yuziform.Nclassid.selectedIndex].value)">
<%
if isNull(Session("Nclassid")) or isEmpty(Session("Nclassid")) then Session("Nclassid") = ""
rs.open "select * from Tbl_Products_nclass " ,conn,1,1
dim selNclassId,strSelected
If not(rs.eof and rs.bof) then
Do while not rs.eof
if CStr(rs("NclassID")) = CStr(Session("NClassID")) then
strSelected = "Selected"
else
strSelected = ""
end if
Response.Write("<option value='"&rs("NClassID")&"' "&strSelected&">"&rs("NClass")&"</option>")
rs.MoveNext
Loop
End If
rs.close
set rs = nothing
%>
</select>
<%
if isNull(Session("Nclassid")) or isEmpty(Session("Nclassid")) then Session("Nclassid") = ""
rs.open "select * from Tbl_Products_nclass " ,conn,1,1
dim selNclassId,strSelected
If not(rs.eof and rs.bof) then
Do while not rs.eof
if CStr(rs("NclassID")) = CStr(Session("NClassID")) then
strSelected = "Selected"
else
strSelected = ""
end if
Response.Write("<option value='"&rs("NClassID")&"' "&strSelected&">"&rs("NClass")&"</option>")
rs.MoveNext
Loop
End If
rs.close
set rs = nothing
%>
</select>
评论: 0 | 引用: 0 | 查看次数: 776
发表评论