Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Anyone know why this is happening?
September 24, 2004, 9:09 am
rate this thread
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?
Re: Anyone know why this is happening?
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