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

Submit button and click vs. enter

P: n/a
All articles and tutorials I've seen on subject of forms say that if
there's name and value for submit button(input tag with
type="submit"), they'll get submitted along with the rest of the
form...

but I've just noticed (after debugging my perl script for quite a
while :/ ) that it is true only when user clicks on submit, and if
form is submitted via hitting enter you don't get name=value for
submit buttton...

Is that supposed to be like that, or I'm doing something wrong?
thanx,
ivan
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
iv********@yahoo.com (ivanhoe) wrote:
All articles and tutorials I've seen on subject of forms say that if
there's name and value for submit button(input tag with
type="submit"), they'll get submitted along with the rest of the
form...

but I've just noticed (after debugging my perl script for quite a
while :/ ) that it is true only when user clicks on submit, and if
form is submitted via hitting enter you don't get name=value for
submit buttton...

Is that supposed to be like that, or I'm doing something wrong?


Nope, that's the way it is.

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 20 '05 #2

P: n/a
iv********@yahoo.com (ivanhoe) wrote:
All articles and tutorials I've seen on subject of forms say that if
there's name and value for submit button(input tag with
type="submit"), they'll get submitted along with the rest of the
form...
Indeed. But since there is so much bogus info in articles and tutorials
on HTML, this should be checked from the specification.
but I've just noticed (after debugging my perl script for quite a
while :/ ) that it is true only when user clicks on submit, and if
form is submitted via hitting enter you don't get name=value for
submit buttton...
By "hitting enter", you presumably mean pressing the enter (return) key
when focused on a text input field. It is possible to tab to a submit
button and then submit the form by hitting enter, but this is a different
case, and I don't know about similar problems with it (it's effectively
equivalent to clicking on the button, except perhaps for handling
event attributes).

The answer is: Maybe, maybe not. The specifications are vague in this
issue, and browser behavior is close to madness. See
http://ppewww.ph.gla.ac.uk/~flavell/...mquestion.html
Is that supposed to be like that, or I'm doing something wrong?


You should not rely on getting the name=value pair when the form is
submitted by hitting enter in a text input field. And you should not rely
on _not_ getting it. This makes multiple submit buttons a risky affair
(if the form contains text input fields, as it usually does). So it is
better to use a different approach, e.g. letting the user make a choice
by selecting among radio buttons (and using a single submit button)
instead of selecting between different submit buttons.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.