Bosconian <bo*******@planetx.com> wrote:
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 (i.e.
"Submit") doesn't pass when pressing enter on another form field.
"Daniel Tryba" <ne****************@canopus.nl> wrote in message
news:cj**********@news.tue.nl... Bosconian <bo*******@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 appear. 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
know this can happen, you know not to depend on an index in _POST called
'Submit'.
--
Daniel Tryba
Submit-fields are only submitted in case the user clicked on them to submit
the form. Otherwise, the name-attribute would be senseless for them because
you could use hidden to archive that goal, too.
Btw: This behaviour is often used in applications, for example all bulletin
boards written in PHP I know offer an optional preview of the posting which
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