I have the paypal payment form
<form name="form1" method="https://www.sandbox.paypal.com/cgi-bin/webscr">
<!-- Resto de input -->
<!-- Botón que ejecuta el direccionamiento al pago paypal-->
<input type="submit" value="paypal sandbox">
</form>
But I want to execute this input
type from another action, I have a link outside the form ( ) so what I want to achieve is that when I click on the following link:submit
form
<a class="checkout" onclick="proceso(2)">Continuar</a>
This executes the following action:
<input type="submit" value="paypal sandbox">
using jQuery or another control.
You can use the same property
onclick
and achieve it in two ways by taking the property ofform
and submitting the form in the following ways:Now if you have multiple forms on the same page that you want to perform the action on, you can identify them using different selectors.
.
#
name
) etc.Example with an
id
add to form = Myform1Another example:
The second way is to execute the
submit
button inside the form, as follows:I leave you two topics related to it in different procedures:
You can give an Id to the button of type submit, for example: "send".
Then, to make that button execute from another action, you can do it with JavaScript in the following way:
Put an event listener on the link you mention, so that the event you listen to is the "click" event. For this you need to put an Id to the link. Then, when the link is clicked, have the button's click event fire as well. In order to manipulate the button you also need to give it an Id. That's why I suggested calling it "send".
You should have something similar to this:
Also, the URL to which you are going to send the data goes in the "action" attribute of the form. In the "method" attribute goes that, the method. I guess it would be POST. Use the one you need.