2017-01-23 62 views
0

我想自動提交此表單20秒,但有些事情是錯誤的,不工作,我沒有任何錯誤消息,我用這個作爲起點獲取用戶名和從URL和替代本成登錄各自領域的密碼,並提交自動提交表單在20秒

<form accept-charset="UTF-8" role="form" class="form-signin" 
 
    id="form" name="{$form_name}" action="{$form_action}" method="post" encType="multipart/form-data" onsubmit="return validateForm('{$form_objectRequiredFields}');"> 
 
    <input type="hidden" class="notValidateThisFields" name="__notValidateThisFields__" id="__notValidateThisFields__" value="{$form_objectRequiredFields}" /> 
 
    <input type="hidden" name="DynaformRequiredFields" id="DynaformRequiredFields" value="{$form_objectRequiredFields}" /> 
 
    {$form.BROWSER_TIME_ZONE_OFFSET} 
 
    <div style="display: none;"> {$form.USR_PASSWORD}</div> 
 
    <fieldset> 
 
     <label class="panel-login"> 
 
     <div class="login_result"></div> 
 
     </label> 
 
     {$form.USR_USERNAME} 
 
     {$form.USR_PASSWORD_MASK} 
 
     {$form.USER_LANG} 
 
     {$form.URL} 
 
     {$form.FAILED_LOGINS} 
 

 
    </fieldset> 
 
    <fieldset> 
 
     <label class="panel-login"> 
 
      <div class="login_result"></div> 
 
     </label> 
 
     <br> 
 
     {$form.BSUBMIT} 
 
     {$form.FORGOT_PASWORD_LINK} 
 

 
    </fieldset> 
 
    <script type="text/javascript"> 
 
     {$form.JS} 
 
    </script> 
 
\t <script> 
 
\t window.onload=function() {literal}{{/literal} 
 
\t \t var x = 20; 
 
\t \t var y = document.getElementById("timer"); 
 
\t \t 
 
\t 
 
\t \t setInterval(function(){literal}{{/literal} 
 
\t \t if(x<=21 && x>=1) 
 
\t \t {literal} { {/literal} 
 
\t \t \t x--; 
 
\t \t \t y.innerHTML= ''+x+''; \t 
 
\t \t \t 
 
\t \t \t if(x==1) 
 
\t \t \t {literal}{{/literal} 
 
\t \t \t x=21; 
 
\t \t \t {literal}} {/literal} 
 
\t \t {literal}} {/literal} 
 
\t \t 
 
\t \t {literal}}{/literal}, 1000); 
 
\t \t 
 
\t 
 

 
    var auto_refresh = setInterval(function() {literal}{{/literal} submitform(); {literal}}{/literal}, 20000); 
 

 
\t 
 
\t function submitform() 
 
\t {literal} { {/literal} 
 
\t \t alert('Form is submitting.....'); 
 
\t \t document.getElementById("form").submit(); 
 
\t \t 
 
\t {literal} } {/literal} 
 
\t </script> 
 
</form> 
 
<script src="/lib/pmdynaform/libs/respondjs/respond.min.js"></script> 
 
<script src="/lib/pmdynaform/libs/html5shiv/html5shiv.js"></script> 
 
<script type="text/javascript"> 
 
    try {literal}{{/literal} dynaformSetFocus();}catch(e){literal}{{/literal}} 
 
</script>

回答

2

試試這個:

$(function(){ // document.ready function... 
    setTimeout(function(){ 
     $('formId').submit(); 
    }, 20000); // In milliseconds - 20 seconds is given here 
}); 
1

您可以嘗試使用window.setTimeout()來執行基於毫秒的函數。

window.setTimeout(submitform, 20000); 

功能submitform將執行後20000ms

3

試試這個

button.onclick=function(){ 
     button.setTimeout(function() { document.formId.submit(); }, 20000); 
    };