|
Posted by J.O. Aho on 02/26/07 13:05
bissatch@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
Navigation:
[Reply to this message]
|