1
使用会话变量来存储复选框的选中状态时出现问题。我正在使用分页,因此当每个字母被按下时,一个复选框将出现,并将相应的字母存储为其值。当一个复选框被选中时,它的状态被保存,但问题是当我取消选中复选框时,它仍然被选中。也不知道这是否相关,但我已经改变了按钮看起来像超链接,所以我可以使用post方法,而不是使用查询字符串,因为我不想使用它。下面提供的代码会话变量经典asp
<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