代码如下:当点击ok按钮时,input  Y中的值会赋给X,然后弹出
confirm对话框,要求当确认时跳转到xy.jsp页面,当点取消时,不跳转
且X中的值为空,如果实现?
<html>  
  <head>  
    <title>test</title>  
  </head>  
  <SCRIPT LANGUAGE="JavaScript">
  <!--
  function qp(){
document.form1.elements["X"].value=document.form1.elements["Y"].value;
}
  //-->
  </SCRIPT>
  <body>  
     <form name="form1" action="xy.jsp" method="post">
 <input type="submit" value="ok" class="button1" name="qu" onClick="qp();return confirm('确认?');" >
       <input  name="X" type="text"  size="8" maxlength="15" readonly>
       <input type="text" name="Y" value="5321">  </form>
  </body>  
</html>  

解决方案 »

  1.   


    <html>  
      <head>  
        <title>test</title>  
      </head>  
      <SCRIPT type="text/javascript">
      <!--
      function qp(){
         document.getElementById("X").value=document.getElementById("Y").value;
          return confirm('确认?')?true:false;
           
    }
      -->
      </SCRIPT>
      <body>  
         <form name="form1" action="xy.jsp" method="post" onsubmit="return qp()">
        
           <input  type="text"  name="X"  id="X" size="8" maxlength="15" readonly>
           <input  type="text" name="Y"  id="Y" value="5321">
        <input type="submit" value="ok" class="button1" name="qu">     </form>
      </body>  
    </html>
    楼主说的是这样的效果吗?
      

  2.   

      function qp()
    {
            document.form1.elements["X"].value=document.form1.elements["Y"].value;
    if(confirm('确认?')){
    window.location="xy.jsp";
    }else{
    document.form1.elements["X"].value='';
    }
    }
    onClick="qp()"
      

  3.   

    当选择(取消时)false时,X中的值要为空,