By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,446 Members | 1,556 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,446 IT Pros & Developers. It's quick & easy.

Anyone know why this is happening?

P: n/a
This is more of an HTML question, but it's related to a PHP project.

I have a simple form consisting of 2 selects, 1 text input and a submit
button. The form action submits to the same page.

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?

Thanks!
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

Jul 17 '05 #2

P: n/a
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

Jul 17 '05 #3

P: n/a
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
Jul 17 '05 #4

P: n/a
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" <si***********@news.slashlife.de> wrote in message
news:yw***************@news.dangerouscat.net...
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

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.