Reply to Re: Is it possible to submit two forms at a time

Your name:

Reply:


Posted by Kimmo Laine on 02/22/07 19:33

mosesdinakaran@gmail.com kirjoitti:
> Hi All,
>
> I need a small clarification in submitting the forms, Ur
> suggestions please.
>
> In a page I have two form and also two submit butons.
>
>
> (ie)
>
> <form name="myform" action="test.php" method="post" >
> <input type="text" name="myform_name" >
> <input type="text" name="myform_id" >
> <input type="text" name="myform_no" >
> <input type="submit" value="Submit" />
> </form>
>
> <form name="myform1" action="test.php" >
> <input type="text" name="myform1_name" >
> <input type="text" name="myform1_id" >
> <input type="text" name="myform1_no" >
> <input type="submit" value="Submit" />
> </form>
>
> Now is it possible to submit all the elements from the two form when I
> click any one of the submit button.

I see absolutely no reason for having two forms. You want to post all
values but possibly handle different actions based on which button was
clcikced, so a clean, non-javascript solution would be just put them all
in the same form and test at server-side which button was clicked if it
matters.

<form name="myform" action="test.php" method="post" >
<input type="text" name="myform_name" >
<input type="text" name="myform_id" >
<input type="text" name="myform_no" >
<input type="submit" name="submit" value="Submit" />
<br />
<input type="text" name="myform1_name" >
<input type="text" name="myform1_id" >
<input type="text" name="myform1_no" >
<input type="submit" name="submit1" value="Submit" />
</form>

test.php:

if(isset($_POST['submit'])){

// Handle the case where the first button was clicked

}

if(isset($_POST['submit1'])){

// Handle the case where the second button was clicked

}

if(sizeof($_POST)){

// Handle the case where it doesn't matter what was clicked.

}

If you do it like this, then it's accessible for them javascriptless
folk too. Ignorance is not a reason to create obstacles.

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация