List Info

Thread: Submit multiple form




Submit multiple form
country flaguser name
United States
2007-06-26 05:21:47
I have search this group without clear success.
If anyone can give me hand please, I need it urgently.

I have 2 forms that I want to submit with a single submit
button
and get the submit date from both forms with $_POST[].
Is this possible?

I have here the two forms.

<form action="register.php"
method="post" name="form1">
<input type="text" name="id">
<input type="submit" name="form1"
value="Submit">
</form>

<form action="register.php"
method="post" name="form2">
<input type="text" name="id2">
<input type="submit" name="form2"
value="Submit">
</form>
<br />
<?php  echo $_POST['id'];?><br />
<?php echo $_POST['id2'];?>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP & MySQL" group.
To post to this group, send email to phpmysqlgooglegroups.com
To unsubscribe from this group, send email to
phpmysql-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/phpmysql?hl=en
-~----------~----~----~----~------~----~------~--~---


RE: Submit multiple form
country flaguser name
South Africa
2007-06-26 05:28:43
I'd Create one form with an onsubmit event, so what you do
is something like
this:
<input type="text"
id="textFieldOne">
<input type="text"
id="textFieldTwo">

<form action="register.php"
method="post" name="newform"
onsubmit="testFunction()">
<input type="hidden" name="id"
id="idField">
<input type="submit"
name="newformsubmitbutton"
value="Submit">
</form>

<script>
function testFunction() {
	if (document.getElementById('textFieldOne').value != '') {
		document.getElementById('idField').value =
document.getElementById('textFieldOne').value;
	} else {
		document.getElementById('idField').value =
document.getElementById('textFieldTwo').value;
	}
}
</script>

What this will do, is when you hit submit, a javascript
function will check
whether the first text field was filled in, if so, it'll
make the hidden
field's value that of the first text field, alternatively
the value of the
second text field. You'd know better what the rules behind
this should be.

You can also have some sort of a "clear" function
that's being called when
you for instance focus on the second text field so it clears
the value out
of the first text field.  This way, you only have the one
form to submit 

Sarel

-----Original Message-----
From: phpmysqlgooglegroups.com [mailto:phpmysqlgooglegroups.com] On Behalf
Of Frederick
Sent: 26 June 2007 12:22 PM
To: PHP & MySQL
Subject: Submit multiple form


I have search this group without clear success.
If anyone can give me hand please, I need it urgently.

I have 2 forms that I want to submit with a single submit
button
and get the submit date from both forms with $_POST[].
Is this possible?

I have here the two forms.

<form action="register.php"
method="post" name="form1">
<input type="text" name="id">
<input type="submit" name="form1"
value="Submit">
</form>

<form action="register.php"
method="post" name="form2">
<input type="text" name="id2">
<input type="submit" name="form2"
value="Submit">
</form>
<br />
<?php  echo $_POST['id'];?><br />
<?php echo $_POST['id2'];?>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP & MySQL" group.
To post to this group, send email to phpmysqlgooglegroups.com
To unsubscribe from this group, send email to
phpmysql-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/phpmysql?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )