注册 登录
编程论坛 ASP技术论坛

返回时,不能正常显示 tp1 或者 tp2

ysf0181 发布于 2010-11-03 13:20, 370 次点击
程序代码:
<%
if request("55")="55" then
   Response.Write (
"<script>alert('友情提示!\n\n返回显示 测试!');history.back();</script>")
        response.end
end if
%>
<html>
<head><title>测试</title>
<script language="JavaScript">
function selectpost(val)
{                  
   
if(val == "11")
    {
        document.all[
"tp1"].style.display = "";
        document.all[
"tp2"].style.display = "none";
     }
   
else if (val == "22")
    {
       document.all[
"tp1"].style.display = "none";
       document.all[
"tp2"].style.display = "";
    }

 }
</script>
</head>
<body onload="selectpost(form1.aa.value)">
<form action="55.asp" type="post" name="form1">
<input type="hidden" name="55" value="55" >
<input type="radio" name="aa" value="11" onclick="selectpost(this.value)">
     <table id="tp1" style="display:none" bgcolor="#CCCCCC">
     <tr><td>tp1显示</td></tr></table>
<input type="radio" name="aa" value="22" onclick="selectpost(this.value)">
      <table id="tp2" style="display:none" bgcolor="#1CCCC1">
     <tr><td>tp2     显示</td></tr></table>

<input type="submit" value="提交">
</form>
</body>
</html>
返回时,不能正常显示 tp1  或者 tp2

[ 本帖最后由 ysf0181 于 2010-11-3 14:08 编辑 ]
2 回复
#2
ysf01812010-11-03 13:28
<%
if request("55")="55" then
   aa=request("aa")
   response.cookies("aa")=aa   
   Response.Write ("<script>alert('友情提示!\n\n返回显示 测试!');history.back();</script>")
        response.end
end if
%>
onload="selectpost(<%=request.cookies("aa")%>)"

是可实现,但是一旦离开这个页面时,这个 cookies("aa") 该如何清除呢,难道设置时间过几秒,这个都不好的。
#3
ysf01812010-11-03 14:16
  还可以从这方面来控制,就是多个 <input type="hidden" name="aa1">
<script language="JavaScript">
function selectpost(val)
{                  
  document.aa1.value=val;   
 if(val == "11")
    {
        document.all["tp1"].style.display = "";
        document.all["tp2"].style.display = "none";
     }
    else if (val == "22")
    {
       document.all["tp1"].style.display = "none";
       document.all["tp2"].style.display = "";
    }
}

<body onload="selectpost(form1.aa1.value)">

呵呵,自己解决了。晕,还没我自己想的快。。。自己想出来了。版主,加精吧,这个是新手经常碰到的问题。
1