| re: Anyone know why this is happening?
Simon,
Thanks for the clarification. I have used multiple submit buttons in a form
before for the purpose you described, but for some reason the behavior in
question was never obvious to me until now.
Regards,
"Simon Stienen" <simon.stienen@news.slashlife.de> wrote in message
news:ywm99077jgai$.dlg@news.dangerouscat.net...[color=blue]
> Bosconian <bosconian@planetx.com> wrote:[color=green]
> > Dan,
> >
> > Thanks for your reply.
> >
> > I have changed my logic to look for one of the form fields instead of
> > "Submit". I'd still like to know why a submit input when given a name[/color][/color]
(i.e.[color=blue][color=green]
> > "Submit") doesn't pass when pressing enter on another form field.
> >
> > "Daniel Tryba" <news_comp.lang.php@canopus.nl> wrote in message
> > news:cj094p$bdd$1@news.tue.nl...[color=darkred]
> >> Bosconian <bosconian@planetx.com> wrote:
> >>> When entering a string into the text input and hitting return (without
> >>> tabbing to and clicking "Submit") the page reloads, but no results[/color]
> > appear.[color=darkred]
> >>> However tabbing to or clicking "Submit" work as expected.
> >>>
> >>> On the server side $_POST['Submit'] exists when tabbing to or clicking
> >>> "Submit", but doesn't when hitting return from the text input.
> >>>
> >>> Can someone tell me why this is happening?
> >>
> >> -Hitting enter in a form with 1 text input firing a submit event is by
> >> design.
> >> -Not getting results sounds like a logic error in your code... now you[/color]
> > know[color=darkred]
> >> this can happen, you know not to depend on an index in _POST called
> >> 'Submit'.
> >>
> >> --
> >>
> >> Daniel Tryba
> >>[/color][/color]
>
> Submit-fields are only submitted in case the user clicked on them to[/color]
submit[color=blue]
> the form. Otherwise, the name-attribute would be senseless for them[/color]
because[color=blue]
> you could use hidden to archive that goal, too.
> Btw: This behaviour is often used in applications, for example all[/color]
bulletin[color=blue]
> boards written in PHP I know offer an optional preview of the posting[/color]
which[color=blue]
> is about to be published. This is determined by specifiing two submit
> buttons with different names and checking, which one has been used to
> submit the form.
> If -on the other hand- a submit button would *always* be transmitted, you
> would always get both buttons and therefore be unable to determine, which
> one the user clicked.
> --
> Simon Stienen <http://dangerouscat.net> <http://slashlife.de>
> »What you do in this world is a matter of no consequence,
> The question is, what can you make people believe that you have done.«
> -- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle[/color] |