<form name="theForm" method="post" action="billaddadmin.asp">
<input type='text' name='billno' value=''>
<input type="button" name="Submit1" value="保 存" onClick=""return Juge()"">
</form><SCRIPT language="javascript"> 
<!--
function Juge()
{
   if (theForm.billno.value == "")
  {
    alert("请填写billno。");
    theForm.billno.focus();
    return (false);
  }   if(confirm("确认保存吗?"))
      //可否在这里写什么代码,让过了两秒后才执行下面的document.theForm.submit()呢?
      document.theForm.submit();
   else
      return false;
}
-->
</SCRIPT>请问:如何实现,点击了保存按钮后,延迟两秒钟再提交呢?或者可否在执行document.theForm.submit()前加入什么代码,使得可以延迟两秒钟再提交呢?

解决方案 »

  1.   

    把submit写成一个函数,加上setTimeout就可以了
      

  2.   

    <form name="theForm" method="post" action="billaddadmin.asp">
    <input type='text' name='billno' value=''>
    <input type="button" name="Submit1" value="保 存" onClick=""return Juge()"">
    </form><SCRIPT language="javascript">  
    <!--
    function Juge()
    {
      if (theForm.billno.value == "")
      {
      alert("请填写billno。");
      theForm.billno.focus();
      return (false);
      }  if(confirm("确认保存吗?"))
      //可否在这里写什么代码,让过了两秒后才执行下面的document.theForm.submit()呢?
      setTimeout('document.theForm.submit();',2000);
      else
      return false;
    }
    -->
    </SCRIPT>
      

  3.   

    window.setTimeout('document.theForm.submit();',2000);
      

  4.   

    setTimeout(function(){document.theForm.submit();},2000);
      

  5.   


    <form name="theForm" method="post" action="billaddadmin.asp">
    <input type='text' name='billno' value=''>
    <input type="button" name="Submit1" value="保 存" onClick="return Juge()">
    </form><SCRIPT language="javascript">  
    <!--
    function Juge()
    {
      if (theForm.billno.value == "")
      {
      alert("请填写billno。");
      theForm.billno.focus();
      return (false);
      }  if(confirm("确认保存吗?")){
      //可否在这里写什么代码,让过了两秒后才执行下面的document.theForm.submit()呢? window.setTimeOut(document.theForm.submit(),2000);
    }
      else{
      return false;
    }
    }
    -->
    </SCRIPT>