2010-07-20 95 views
0

我想從另一個表單輸入按鈕的表單中觸發特定的輸入按鈕。就好像有人點擊了該按鈕,而不是像在此線程中的答案那樣提交表單。這是我想要觸發的那個。從另一個表單輸入按鈕中觸發一個表單中的特定輸入按鈕

<td width="135" align="right"><input border="0" type="image" id="btnRecalculate" name="btnRecalculate" src="v/vspfiles/templates/100/images/buttons/btn_recalculate.gif" alt="Recalculate Totals"></td> 

previous question

<form method="POST" name="form" action="ShoppingCart.asp" onsubmit="if (typeof(Update_Hidden_State_Fields)=='function') Update_Hidden_State_Fields(); if (this.submitted) return false; else {this.submitted=true; return true;}"> <td><center><input type="text" maxlength="7" size="5" value="5" name="Quantity1" id="Quantity1"><center></td> 
<td><center><input type="text" maxlength="7" size="5" value="2" name="Quantity2" id="Quantity2"><center></td> 
<td><center><input type="text" maxlength="7" size="5" value="5" name="Quantity3" id="Quantity3"><center></td> 
<td width="135" align="right"><input border="0" type="image" id="btnRecalculate" name="btnRecalculate" src="v/vspfiles/templates/100/images/buttons/btn_recalculate.gif" alt="Recalculate Totals"></td></form> 

這是第二種形式

<form name="Proceed_To_Checkout_Form" method="post" action="https://www.dothisurl.com/login.asp"> 
<td><input type="image" src="v/vspfiles/templates/100/images/buttons/btn_checkout_guest.gif" name="btn_checkout_guest"></td> 
<td><input type="image" src="v/vspfiles/templates/100/images/buttons/btn_checkout_guest.gif" name="btn_checkout_guest"></td></form> 

這是以前的答案給出

$(function(){ 
$("[id^='Quantity']").each(function(){ 
$(this).data('default', $(this).val()); 
}); 

$("[name='Proceed_To_Checkout_Form']").submit(function(){ 
var hasChanged = false; 
$("[id^='Quantity']").each(function(){ 
    if($(this).val() != $(this).data('default')){ 
    hasChanged = true; 
    } 
}); 
if(hasChanged){ 
    $("[name='form']").submit(); 
    return false; 
} 
}); 
}); 

回答

相關問題