我写了这样一个代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
  <script language="javascript">
    function choose()
   {
     
 
    confirm("我被单击了");
  
}
function choose1()
{
  var made=confirm("重新定义");
 
 }
 function choose2()
 {
   confirm("提交");
 
  }
 
     }
</script>
</head><body>
<center>
<form action="" name="women">
<input type="text" name="x1" id="x1" size="20" /><br />
<input type="button" name="x4" id="x4" onClick="choose()" value="确定"/>
<input type="reset" name="x3" id="x3" value="重置" onClick="choose1()"/>
<input type="submit" name="x2" id="x2" value="提交" onClick="choose2()" />
</form>
</center>
</body>
</html>
我想实现在选择重置和提交的时候,那个文本框里面输入的文字不消失,在点重置时,弹出的窗口点确定文本框的文字消失,点取消让文本框的文字不消失,提交也是如此,怎么改?为什么我点了取消,文本框输入的东西还是不见了?怎么样可以实现我说的这个问题?

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
      <script language="javascript">
    function choose() {
    confirm("我被单击了");
    }
    function choose1(){
    return confirm("重新定义");
    }
    function choose2(){
    return confirm("提交");
    }
    </script>
    </head><body>
    <center>
    <form action="" name="women">
    <input type="text" name="x1" id="x1" size="20" /><br />
    <input type="button" name="x4" id="x4" onClick="choose()" value="确定"/>
    <input type="reset" name="x3" id="x3" value="重置" onClick="return choose1()"/>
    <input type="submit" name="x2" id="x2" value="提交" onClick="return choose2()" />
    </form>
    </center>
    </body>
    </html>onclick是接受返回值的,如返回false会取消执行。
      

  2.   

    onClick="return choose1()";choose1如果是true 则执行,否则不执行。