Reputation: 1706
I have search a lot but I couldn't find / understand a way to solve this.
I have to forms in the same page.
<form id="inquiry_theme_form" name="inquiry_theme_form" action"#" method="post">
/*Some fields etc*/
<button type="button" value="Go" id="inq_btn_sumbit" name="inq_btn_sumbit">Go</button>
</form>
<form id="booking_form" name="booking_form" action"#" method="post">
/*Some fields etc*/
<button type="button" name="book_btn_submit" id="book_btn_submit">Book now</button>
</form>
I set the type of buttons to button because I want to validate some fields before posting. So If the user has fill all the fields I post the form with jquery.
$("#inq_btn_sumbit").click(function() {
var the_form = $("#inquiry_theme_form");
/* Validation */
if(error){
/*Warn the user*/
}
else{
the_form.submit();
}
});
$("#book_btn_submit").click(function() {
var the_form = $("#booking_form");
/* Validation */
if(error){
/*Warn the user*/
}
else{
the_form.submit();
}
});
On the same page where I have the forms I have this code at the top of the page.
if($_SERVER['REQUEST_METHOD'] == "POST"){
/*I WANT HERE TO SOMEHOW CHECK WHICH FORM HAS BEEN SUBMITTED*/
}
So how I can identify which button the user press namely which form has been submitted
Sorry for my English and thanks for your help!!
Upvotes: 0
Views: 81
Reputation: 6527
You can check which one was submited using a <input type="hidden" name="form" value"form1" />
.
Upvotes: 3