0

I want to trigger a specific input button in a form from another forms input buttons. As if someone clicked on that button not just submit the form as in the answer in this thread. This is the one I want triggered.

<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>

this is the second 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>

This is the previous answer given

$(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;
}
});
});

1 Answer 1

1

Try this: $('#btnRecalculate').trigger('click');

More info here: http://api.jquery.com/trigger/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.