会话变量经典asp
使用会话变量存储复选框的选中状态时遇到问题。我正在使用分页,因此当按下每个字母时,将出现一个复选框,并将相应的字母存储为其值。当选中复选框时,其状态将被保存,但问题是,当我取消选中该复选框时,它仍保持选中状态。也不知道这是否相关,但我已将按钮更改为看起来像超链接,因此我可以使用 post 方法而不是使用查询字符串,因为我不想使用它。下面提供的代码
<form action="Table.asp" method="post" name="form2">
<input type="submit" name="Button" value="#" style="background:transparent;border:0;display:inline;color:#00F;text-decoration:underline;padding:0px;cursor:pointer">
<% for i = 97 to 122 %>
<input type="submit" name="Button" value="<%=CHR(i) %>" style="background:transparent;border:0;display:inline;color:#00F;text-decoration:underline;padding:0px;cursor:pointer;">
<% next %>
</br></br></br>
<%
alphaB = request.form("Button")
if alphaB <>"" then
alphaCheck = request.form("checkBox")
if alphaCheck <>"" then
session("checkBox_"&alphaCheck) = "checked"
else
session("checkBox_"&alphaCheck) = ""
end if
%>
<input type="checkbox" name="checkBox" value="<%=alphaB %>" <%=session("checkBox_"&alphaB) %>>
<%
response.write alphaB
end if
I have a problem when using session variables to store the checked state of a checkbox. I'm using pagination so when each letter is pressed a checkbox will appear with the respective letter stored as its value. When a checkbox is checked its state is saved, however the problem is that when i uncheck the checkbox it remains checked. Also dont know if this is relevant but I've changed the buttons to look like hyperlinks so i can use post method instead of using querystring as I'd prefer not to use it. Code provided below
<form action="Table.asp" method="post" name="form2">
<input type="submit" name="Button" value="#" style="background:transparent;border:0;display:inline;color:#00F;text-decoration:underline;padding:0px;cursor:pointer">
<% for i = 97 to 122 %>
<input type="submit" name="Button" value="<%=CHR(i) %>" style="background:transparent;border:0;display:inline;color:#00F;text-decoration:underline;padding:0px;cursor:pointer;">
<% next %>
</br></br></br>
<%
alphaB = request.form("Button")
if alphaB <>"" then
alphaCheck = request.form("checkBox")
if alphaCheck <>"" then
session("checkBox_"&alphaCheck) = "checked"
else
session("checkBox_"&alphaCheck) = ""
end if
%>
<input type="checkbox" name="checkBox" value="<%=alphaB %>" <%=session("checkBox_"&alphaB) %>>
<%
response.write alphaB
end if
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在回发之前保存“未选中”的值,然后使用该值。
You should save the value you 'unchecked' before you postback, and then use this value.
我要做的是使用隐藏字段来保存最后一个字母
what i would do is use a hidden field to save the last letter