2012-07-25 71 views
0

我有兩個頁面上的按鈕:添加onsubmit屬性,形成並提交

<div class="bottons"> 
     <button class="wiz_button wizard_prev_step" type="button" style="margin-top: 27px; 
      display: none"><span><span>Previous</span></span></button> 
     <form id="orderForm" method="POST"> 
     <input type="hidden" name="Signed_Order_B64" value=""> 
     <input type="hidden" name="email" size="50" maxlength="50" value=""> 
     <input type="hidden" name="Language" value="rus"> 
     <input type="hidden" name="firstname" value=""> 
     <input type="hidden" name="surname" value=""> 
     <input type="hidden" name="appendix" value="">    
     <button class="wiz_button wizard_next_step disabled long" type="button" style="margin-top: 27px;"> 
      <span><span>Next</span></span></button> 
     </form> 
    </div> 

從我的自定義嚮導此按鈕。另外,我有一個click事件處理程序Next按鈕:

$('.wizard_next_step').click(function() { 
// load next step and other stuff 
}) 

我想,當用戶在最後一步找到職位形式:

if (currentStep === '3') { 
// here I want set onsubmit function for the form * 
} 

我怎樣才能做到這一點?
謝謝。

PS。該解決方案必須在IE 7及更高版本中運行。

+0

你可能檢查出[這個插件(http://elclanrs.github.com/jq-idealforms/) – elclanrs 2012-07-25 04:36:57

回答

1

只要做到:

$('#orderForm').submit() 
0

您正在使用jQuery。所以簡單地用

if (currentStep === '3') { 
// here I want set onsubmit function for the form and submit it * 
    $('#orderForm').submit(); 

} 
0

由於按鈕的形式,以及連接監聽器內this將引用按鈕,則可以使用分配給的onsubmit屬性:

this.form.onsubmit = someFn; 

,並使用提交表單:

this.form.submit();