|
Posted by kenoli on 02/27/07 16:41
This is timely for me as well. I was trying to figure out how to
process diferent groups of form imput and discovered that form names
are not sent via the $_POST variable. Your way of coding this is a
good solution. I presume when using multiple forms like this, a
submit in a given form only sends data from the input fields in that
form rather than from all the forms on the page. Is this true?
--Kenoli
On Feb 26, 11:04 am, "shimmyshack" <matt.fa...@gmail.com> wrote:
> On 26 Feb, 13:05, "J.O. Aho" <u...@example.net> wrote:
>
>
>
> > bissa...@yahoo.co.uk wrote:
> > > Hi,
>
> > > When I submit a form, I use the $_POST thingy to get the form values.
> > > Is it possible to get the form name from this method?
>
> > > For example:
>
> > > <form name="form1" method="post" action="...">
> > > <input type="text" name'"name"... .
> > > </form>
>
> > > When I submit the form I will get the POST variable "name" as well as
> > > any other form elements that are submitted. Can I also get the form
> > > name, "form1"?
>
> > No, the form "name" isn't sent with the form submit, the "name" option
> > is a depricated way of selecting the correct style from CSS or target
> > the right part of the page with javascript, it's higly encuraged that
> > people shouldl use "id" instead of "name".
> > And the answer for your next question is, no, the "id" won't be sent
> > when you submit the form, it's still used for CSS and javascript.
>
> > If you want to send a "form id" then either use the submit button or use
> > a hidden input field
>
> > example 1 (button):
>
> > <form method="post" action="...">
> > <input type="text" name'"name"...
> > <button type="submit" name="form1" value="form1">Submit</button>
> > </form>
>
> > example 2 (hidden):
>
> > <form method="post" action="...">
> > <input type="text" name'"name"...
> > <inout type="hidden" name="form1" value="form1">
> > <button type="submit">Submit</button>
> > </form>
>
> > Keep in mind that method 1 don't work on the broken browser, but works
> > fine in khtml/gecko/opera.
>
> > --
>
> > //Aho
>
> you can also choose to name you fields after the form (here are 2
> forms in the same page)
> <html>
> <head></head>
> <body>
> <form method="post" action="..." name="form2">
> <input type="text" name="form1[field1]"... />
> <input type="text" name="form1[field2]"... />
> <button type="submit">Submit</button>
> </form>
> <form method="post" action="..." name="form2">
> <input type="text" name="form2[field1]"... />
> <input type="text" name="form2[field2]"... />
> <button type="submit">Submit</button>
> </form>
> </body>
> </html>
>
> you then use an array called by the name of the form to get the values
> out in say php
Navigation:
[Reply to this message]
|