• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

Submitting multiple forms using javascript's submit()

Hi

I have 2 forms on the same page. I use this for the submit buttons:

<INPUT onclick=document.f1.submit(); type=button value="Send f1">
f1 is form name

on the 2nd form:

<INPUT onclick=document.f2.submit(); type=button value="Send f2">
f2 is form name

The problem is in my PHP script. How do I know when the different forms were submitted?
I try
if(isset($_POST['submit']))
but it doesn't work.

Only if I define the button with type=submit does it work.

Also how do I tell which form was sent?

Thanks
tr5

0
tr5
Asked:
tr5
1 Solution
 
RoonaanCommented:
Add an hidden input field in both forms:

<input type="hidden" name="sourceForm" value="form1" />

Then use:

if(isset($_POST['sourceForm']) && $_POST['sourceForm'] == 'form1') {
}

-r-
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now