Is it possible to determine the name of the form that caused a page to
be submitted? I have seen numerous examples of how to determine the
method of the POST and how to retrieve data elements from the post,
but I haven't seen any way to know the name of the form that caused
the post.
The page that is POSTing to my script has two forms and I'd like to
know if I can determine which one of them was submitted without having
to add a hidden element to the forms.
Thanks, Tyler
Re: Name of the Form that was POSTed?
am 22.08.2007 16:26:15 von Michael Fesser
..oO(Tyler)
>Is it possible to determine the name of the form that caused a page to
>be submitted?
Forms don't have a name. Any 'name' or 'id' attributes applied to a form
can be used in client-side scripting, but are not submitted to the
server.
>The page that is POSTing to my script has two forms and I'd like to
>know if I can determine which one of them was submitted without having
>to add a hidden element to the forms.
IMHO using a hidden element is the most reliable and safest way.
Another way would be to give the submit buttons in each form different
names and check which button was pressed, but this might not always work
as expected.
Micha
Re: Name of the Form that was POSTed?
am 22.08.2007 21:54:45 von jodleren
On Aug 22, 4:59 pm, Tyler wrote:
> Is it possible to determine the name of the form that caused a page to
> be submitted? I have seen numerous examples of how to determine the
> method of the POST and how to retrieve data elements from the post,
> but I haven't seen any way to know the name of the form that caused
> the post.
>
> The page that is POSTing to my script has two forms and I'd like to
> know if I can determine which one of them was submitted without having
> to add a hidden element to the forms.
It sounds like a system I have used. Say, a number of forms, buttons
whatever, you need to know what the i.... at the other end did.
First some JS:
function setbuttonname(input)
{
document.forms[0].buttonname.value=input;
document.forms[1].buttonname.value=input;
....
}
then the button
onclick="setbuttonname(this.name);"...
Idea: I get the name of button pressed - this tells me very exact what
the user did.
HTH
Sonnich
Re: Name of the Form that was POSTed?
am 22.08.2007 23:45:53 von yf110
jodleren (sonnich@hot.ee) wrote:
: On Aug 22, 4:59 pm, Tyler wrote:
: > Is it possible to determine the name of the form that caused a page to
: > be submitted? I have seen numerous examples of how to determine the
: > method of the POST and how to retrieve data elements from the post,
: > but I haven't seen any way to know the name of the form that caused
: > the post.
: >
: > The page that is POSTing to my script has two forms and I'd like to
: > know if I can determine which one of them was submitted without having
: > to add a hidden element to the forms.
: It sounds like a system I have used. Say, a number of forms, buttons
: whatever, you need to know what the i.... at the other end did.