RT, 我的页面里有表头表体 当用户选择进入表体时要先判断 表头的内容是不是已经 保存.下面是我的把页面分成表头表体的代码
<script language="javascript">function enterJob(id){
       if(id==0){
              if(document.getElementById("b").style.display=="block")
              {
                document.getElementById("b").style.display="none";
              }
             if(document.getElementById("b").style.display=="none")
              {
                document.getElementById("a").style.display="block";
              }
         }
       if(id==1){
              if(document.getElementById("a").style.display=="block")
              {
                document.getElementById("a").style.display="none";
              }
             if(document.getElementById("a").style.display=="none")
              {
                document.getElementById("b").style.display="block";
              }
         }
}
</ script ><body><table width="25%" cellspacing="0" cellpadding="0" class=httable01>
<tr>
<td height="20" width="40" align="center"
onmouseover="this.style.cursor='hand'"
style="padding-right:0px;width:100px;background-image:url('<c:url value='/images/bom1.jpg'/>'); background-repeat: no-repeat; background-position: right center">
<span onclick="enterJob(0)"><font
style="font-size:13px;font-family:黑体">作业单表头</font> </span>
</td>
<td height="20" width="40" align="center"
onmouseover="this.style.cursor='hand'"
style="padding-right:0px;width:100px;background-image:url('<c:url value='/images/bom1.jpg'/>'); background-repeat: no-repeat; background-position: right center">
<span onclick="enterJob(1)"><font
style="font-size:13px;font-family:黑体">作业单表体</font> </span>
</td>
</tr>
</table>
</body>

解决方案 »

  1.   

    我的保存方法
    function save()
    {
      var myform = document.getElementById("InspectionWorkForm");
    if(myform != null && document.getElementById("checkNo").value!=""){
      var r = confirm("确认保存吗");
    if(r){
    uri = "../InspectionWork.do?method=save"
    }else{
    return false;
    }
       uri=encodeURI(uri);
    myform.action=uri;
    myform.submit();
    var bj =document.getElementById("checkNo")     
    }

    } 在保存里做标记的话该怎么办??
      

  2.   

    定义一个全局变量,默认是没有保存的状态,保存后改变状态,在需要时判断此标志
    if(r){
    uri = "../InspectionWork.do?method=save"
    //保存后改变状态
    }
      

  3.   

    我定义个全局变量all
    <script language="javascript">
    var all=0;------------------------------------------------------
    保存时赋予全局变量一个新值
    function save()
    {
      var myform = document.getElementById("InspectionWorkForm");
    if(myform != null && document.getElementById("checkNo").value!=""){
      var r = confirm("确认保存吗");
    if(r){      
    uri = "../InspectionWork.do?method=save"
    //给全局变量一个新值 all++;
    }else{
    return false;
    }
       uri=encodeURI(uri);
    myform.action=uri;
    myform.submit(); }

    }
    ------------------------------------------------------------
    当进去表体时 判断all的值 如果是0弹出提示,1就正常进入function enterJob(id){
    //进入表头
           if(id==0){
                  if(document.getElementById("b").style.display=="block")
                  {
                    document.getElementById("b").style.display="none";
                  }
                 if(document.getElementById("b").style.display=="none")
                  {
                    document.getElementById("a").style.display="block";
                  }
             }
    //进入表体
           if(id==1){
               //判断all的值 1进去,0弹出提示
               if(all=0)
                 {
                 alert("请先保存表头");
                 return false;
                 }else (all=1)
                 {
                 
                  if(document.getElementById("a").style.display=="block")
                  {
                    document.getElementById("a").style.display="none";
                  }
                 if(document.getElementById("a").style.display=="none")
                  {
                    document.getElementById("b").style.display="block";
                  }
             }
           }  
    }
    我这个写的可是没效果啊~~~~~我是不是哪里写错了???
      

  4.   

    if(all=0)
     改成if(all == 0)