here is the sample code.
<form id="form1" name="form1" action="phpPage.php" method="POST">
<!--5 diff values in form1 . . . -->
<input id="b1" onclick="functionOne();">
</form>
<form id="form2" name="form2" action="phpPage.php" method="POST">
<!-- 5 diff values in form2 . . . -->
<input id="b2" onclick="functionTwo();">
</form>
i have up to 8 forms.
The problem is when I click the button b5
, after all the validation checks have performed, I want it so it sends all values from form1
-form5
. I have collected the values in JS function (functionFive()
;) through jQuery. How can I send these values to the phpPage.php
?
Remembering that we have fired the onclick
event on b5
and, as the result, the functionFive
has been called for validation checks. How do I send the values from here to php page?
The answer is to use ONE FORM that encompasses all the values.
Have you tried ajax?
var formData = {
firstName: 'Dennis',
lastName: 'Martinez'
};
$.ajax({
type: 'post',
url: 'SOMEFILE.php',
data: formData,
success: function(e) {
alert('success!');
},
error: function(e) {
alert('there was an error!');
}
});