当前位置: 代码迷 >> JavaScript >> 高分,js history.go(-1)返回有关问题
  详细解决方案

高分,js history.go(-1)返回有关问题

热度:520   发布时间:2012-04-26 14:01:31.0
高分求助,js history.go(-1)返回问题
问题现象为,点击添加后,条件不符的情况下使用 js history.go(-1)后,这时‘提醒时间’这行为默认值了(须不为默认值),例如选radio‘周’后返回‘周’的选择页面才是我想要的,现在是再次点radio '周' 才可以(submit前的值还在),该如何处理这个情况,各位帮忙啊。(我自己感觉,如果用cookies,返回时用得到的cookies再次执行sd_hide(id),我js不熟)
HTML code


<SCRIPT language=javascript>
function sd_hide(id)
     {
    var sd_endtime = document.getElementById('sd_endtime');
    var y_word = document.getElementById('y_word');
    var m_word = document.getElementById('m_word');
    var d_word = document.getElementById('d_word');
    var sd_week = document.getElementById('sd_week');
    var sd_month = document.getElementById('sd_month');
    var sd_day = document.getElementById('sd_day');
    var sd_number = document.getElementById('sd_number');
    var mg_word = document.getElementById('mg_word');
    
    if(id.value == -1) {
    y_word.innerHTML="";
    m_word.innerHTML="";
    d_word.innerHTML="";
    sd_week.style.display='none';
    sd_day.style.display='none';
    sd_month.style.display='none';
    sd_endtime.style.display='none';
    sd_number.style.display='none';
    mg_word.style.display='none';
     } 
    else if(id.value == 'yyyy') {
    y_word.innerHTML="年:";
    m_word.innerHTML="月";
    d_word.innerHTML="日";
    sd_week.style.display='none';
    sd_day.style.display='';
    sd_month.style.display='';
    sd_endtime.style.display='';
    sd_number.style.display='';
    mg_word.style.display='';
    }
    else if(id.value == 'm') {
    y_word.innerHTML="月:";
    m_word.innerHTML="";
    d_word.innerHTML="日";
    sd_week.style.display='none';
    sd_month.style.display='none';
    sd_day.style.display='';
    sd_endtime.style.display='';
    sd_number.style.display='';
    mg_word.style.display='';
    }
    
    else if(id.value == 'ww') {
    y_word.innerHTML="周:";
    m_word.innerHTML="";
    d_word.innerHTML="";
    sd_month.style.display='none';
    sd_day.style.display='none';
    sd_week.style.display='';
    sd_endtime.style.display='';
    sd_number.style.display='';
    mg_word.style.display='';
    }
                    }
                    
</SCRIPT>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="css/css.css">
<title>上海富士达电梯研发有限公司</title>
</head>
<body  topmargin="0" leftmargin="0" onLoad="">
<form method=post name="form1" action="scheduleadd.asp">
  <table border="0" cellpadding="0" cellspacing="0" width="500">
    <tr align="left">
      <td>提醒类型:</td><td>
           <input type="radio"  name="sd_interval" id="-1" value="-1" onclick='sd_hide(this)' >一次性提醒
         <input type="radio"  name="sd_interval" id="ww" value="ww" onclick='sd_hide(this)'>周
         <input type="radio"  name="sd_interval" id="m" value="m"  onclick='sd_hide(this)'>月
         <input type="radio"  name="sd_interval" id="yyyy" value="yyyy" onclick='sd_hide(this)' checked>年
      </td>
        </tr>
    <tr align="left">
      <td>开始使用时间:</td><td width="400">
       <input name="startdate" type="text" class="style2"  onfocus="if (this.value==this.defaultValue) this.value='';" onblur="if (this.value=='') this.value=this.defaultValue;" onclick="new Calendar().show(this);" value="<%=date()%>" size="10"  maxlength="10" readonly="readonly"/>
       </td>
    </tr>
       <tr>
         <td >提醒时间:</td>
         <td>
         <span id='mg_word'>每隔</span> <input type="text" name="sd_number" id="sd_number" size="2" maxlength="2" value="1" onblur="checkObj('sd_number')"></input>
         <span id='y_word'>年</span>
         <select size=1 id="sd_week" name="sd_week" style="display:none;">
               <option value="2">星期一</option>
               <option value="3">星期二</option>
               <option value="4">星期三</option>
               <option value="5">星期四</option>
               <option value="6">星期五</option>
               <option value="7">星期六</option>
               <option value="1">星期日</option>
        </select>
                <select size=1 name="sd_month" id="sd_month">
<%
for i=1 to 12
%>
          <option value="<%=i%>"><%=i%></option>
<%
next
%>
        </select>
        <span id='m_word'>月</span>
        <select size=1 name="sd_day" id="sd_day">
<%
for i=1 to 31
%>
          <option value="<%=i%>"><%=i%></option>
<%
next
%>
        </select>
        <span id='d_word'>日</span>
        <select size=1 name="starthour" id="sd_hour">
<%
for i=8 to 18
%>
          <option value="<%=i%>"><%=i%></option>
<%
next
%>
        </select>时
        <select size=1 name="startminute" id="sd_minute">
<%
for i=0 to 50 step 10
%>
          <option value="<%=i%>"><%=i%></option>
<%
next
%>
        </select>分</td>
    </tr>
    <tr align="left" id='sd_endtime'>
      <td>结束使用时间:</td><td>
       <input name="enddate" type="text" class="style2"  onfocus="if (this.value==this.defaultValue) this.value='';" onblur="if (this.value=='') this.value=this.defaultValue;" onclick="new Calendar().show(this);" value="2999-12-31" size="10"  maxlength="10" readonly="readonly"/> 
        </td>
    </tr>
  </table>
<input type="hidden" name="starttime">
<input type="hidden" name="endtime">
<input type="submit" name="submit" value="添加" onclick="checktime();">&nbsp;&nbsp;&nbsp;<input type="button" value="返回" onclick="window.location.href='schedule.asp'">
</form>
</center></td>
  </tr>
</table>
</body>
</html>

 
  相关解决方案