I have two forms, I need one submit button for two forms. How I can do it, without ajax?
<form action="" id="form" method="post">
<input type="file" name="file">
<input type="text" name="text">
</form>
<form action="" id="form2" method="post">
<input type="file" name="file">
<input type="text" name="text">
</form>
I know that this topic has been raised more than once, but it's not a duplicate, as I need it without ajax
You can use Document.forms which returns a collection.Thereafter forms[0] will return the first form from DOM and so on .Then you can use one button to submit the forms
<button type = "button" onclick="submitForm()">Submit</button>
function submitForm(){
document.forms[0].submit();
document.forms[1].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