I have two HTML forms on one page. I am copying the data from the first form #MemberForm
to another form which won't be visible in the end #InvisibleForm
. I can't seem to get the two forms to submit together at the same time.
First I have some jQuery copying the data from the first form to the second form when I hit submit:
$(function() {
$('#catupdatedetailsformbutton').click(function() {
var form1 = $('#MemberForm').find(':input');
var form2 = $('#InvisibleForm');
form1.each(function() {
var $t = $(this);
form2.find('[name="' + $t.attr('name') + '"]').val($t.val());
});
});
});
I'm not aware of how to submit two forms with any jQuery but I wrote up some JS that isn't working. I've placed it after the jQuery with an onclick="submitForms()"
in the submit button but it doesn't submit both forms.
submitForms = function() {
document.getElementById("MemberForm").submit();
document.getElementById("InvisibleForm").submit();
}
Am I missing something? Can someone point me in the right direction? I've never attempted something like this before!