I have HTML two forms, one that submits data upon entry to a database using PHP, the other directs the user to a paypal payment page, my problem is that the user would have to submit both forms which of course I do not want them to have to do. Is there anyway to use one submit button for two forms?
(Javascript is welcome)
yes, multiple submit buttons can include in the html form. One simple example is given below.
Well, If you are sending both these forms in the same request, then you can make a form object inside the parent component and then pass the form object to the children form and bind it. And then on Submit just post the data which is in the object.
First form is embed form from external website (vTiger webform) with action="https://***/crm/modules/Webforms/capture.php" method="post" Second form is FormIt-based form with preHook, which generate “form name”, “user_id” and “form_id” (value from TV). I save data from this form in another column is SQL-db.
Let's learn the steps of performing multiple actions with multiple buttons in a single HTML form: Create a form with method 'post' and set the value of the action attribute to a default URL where you want to send the form data. Create the input fields inside the as per your concern. Create a button with type submit.
You should be able to do this with JavaScript:
<input type="button" value="Click Me!" onclick="submitForms()" />
If your forms have IDs:
submitForms = function(){ document.getElementById("form1").submit(); document.getElementById("form2").submit(); }
If your forms don't have IDs but have names:
submitForms = function(){ document.forms["form1"].submit(); document.forms["form2"].submit(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With