Here's is a summary of my code
<form class=”form1” action=”action.php” method=”POST”>
//some code
</form>
<form class=”form2” action=”action.php” method=”POST”>
//some code
</form>
<form class=”form3” action=”action.php” method=”POST”>
//some code
</form>
<button id=”submit” type=”submit” name=”submit_changes”>Save Changes</button>
SUPPOSE script to submit all forms
<script>
document.getElementById('submit').addEventListener('click', function() {
// check for and report errors here
for (var i = 0; i < document.forms.length; i++) {
document.forms[i].submit();
};
console.log(document.forms.length);
});
</script>
I realized that after clicking the button "Save Changes", my action.php seems only to process the last form i.e form with class attribute class="form3" I realized that the form tag is an async function. If one has many forms in his file with one submit button the submit button won't submit all the forms but the last because of its asynchronous nature. I'm a self-taught web developer, any corrections or solutions are welcomed. It has been a week since I am trying to solve this issue.