Name and value of submit item not being sent as part of content data.

VERIFIED WORKSFORME

Status

()

Core
HTML: Form Submission
VERIFIED WORKSFORME
16 years ago
16 years ago

People

(Reporter: Richard Heurtley, Assigned: John Keiser (jkeiser))

Tracking

Trunk
x86
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

16 years ago
The URL provided is a form with some simple JavaScript generated by a CGI program. 

The purpose of the JavaScript is to submit the form as if the "goto" button was
clicked when the [Enter] key is pressed while entering data into the "where" field.

It works with IE5.5 and Netscape 4.79 but does not work with Mozilla 1.0.

With IE5.5 and Netscape 4.79 the content data sent to the CGI program looks like
this (with "500" entered into the "where" field:

goto=%A0%A0%A0%A0%A0&where=500&_group=6e187f91...

With Mozilla 1.0 the content data looks like this:

where=500&_group=6e187f91...

The "goto=%A0%A0..." term isn't there.

I added some debugging code to the JavaScript and verified that the
element.click() call is occuring. I also tried calling element.focus() prior to
element.click() to no avail. I looked at the Mozilla Javascript porting guide
and I don't think I'm trying to use unstandard and unsupported functionality.

Comment 1

16 years ago
Browser, not engine ---> Form Submission
Assignee: rogerl → alexsavulov
Component: JavaScript Engine → Form Submission
QA Contact: pschwartau → vladimire

Comment 2

16 years ago
-->
Assignee: alexsavulov → jkeiser
(Assignee)

Comment 3

16 years ago
Need instructions to reproduce.  There are a lot of buttons on that page.  The
problem is most likely that you are doing form.submit(); inside an onClick
handler of a submit button.  form.submit() in *all* browsers does not send the
name/value of the submit button.  That happens after the onClick handler has
finished--the form is submitted a second time (form.submit() was the first),
this time with the goto name/value.  This is the one you will eventually see.

Mozilla protects you from submitting twice and does not send the second submit.
 This is the source of the problem.

You can fix the problem by just not calling form.submit() in the onclick handler.
(Reporter)

Comment 4

16 years ago
The JavaScript doesn't call form.submit() and doesn't have an onClick() 
handler. It calls element.click() inside an onKeyPress() handler.

Sorry about the long form. The only relevent button is the one named 
"goto". On the form it's to the left of the "Goto record" label.

To reproduce, bring up the form, enter a number in the "Goto record" field, 
and press [Enter]. The submitted data doesn't have a "goto=..." item. Under 
Internet Explorer and Netscape 4.7 there is a "goto=..." item.

I don't think that in this case IE and NS 4.7 are submitting the form 
twice. My CGI application throws a security alert when it gets a request 
without a submit name/value. I only see these alerts with Mozilla.

Comment 5

16 years ago
I've got the same problem after upgrading to 1.0 (0.9.7 and 0.9.8. worked fine).
Here is the "problem" code (this.submit() is called but the name and value of
submit are not passed along):

<form action="/cgi-bin/con/usched" method="post" onSubmit='if
(chkinp(this,"Add")) {this.submit()} else{return false;}'>
<input type="hidden" name="subdep" value="70">
<select name="user" size=10>
<option value="621">Someone
</select>
<select name="act" size=10>
<option value="1">Something
</select>
<input type="submit" name="Insert" value="Add">
<input type="submit" name="InsertS" value="As of Today"></form>
(Assignee)

Comment 6

16 years ago
Created attachment 91109 [details]
Richard's Testcase

This is Richard's testcase.  It seems to work.	I clicked on #21 and it
submitted the submit button value (row20=?????) and I clicked on the first
submit button and it submitted main=?????.  All seems well.
(Assignee)

Comment 7

16 years ago
Richard: which button do I have to press on that?  I changed the action on your
form to a host that is reachable on the Internet (that happens to print out post
values) and uploaded.  There seem to be no problems.

Tevel: your problem is different from his, if he has one--his doesn't seem to
have form.submit() in it.  Your problem can be solved by replacing
"form.submit()" with return true;.  It results from our double submit
protection.  form.submit() *always* submits without name and value, but the
submit handler for the button (what happens when you return true from the
onSubmit event) submits the name/value of the button.
(Assignee)

Comment 8

16 years ago
Tevel: http://mozilla.freezope.org/docnotes/FormBugsFAQ#submit_name_value
(Reporter)

Comment 9

16 years ago
I uploaded a much shorter test form to 
http:\\www.heurtley.com\richard\short.html .

You'll still need to edit it to submit to a CGI program that'll show the 
content.

Enter a number (like 555) into the text field.
If you click on the button the content is "goto=%A0%A0%A0%A0%A0;where=555"
If you press [Enter] the content is "where=555".

The (probably very bad) JavaScript calls the element.click() function to 
simulate a button click when [Enter] is pressed.

Comment 10

16 years ago
This is what I get from the short testcase on win98 build 2002-07-10-08-trunk:
goto=%A0%A0%A0%A0%A0&where=123
Can you retest with a recent nightly build?
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → WORKSFORME
(Reporter)

Comment 11

16 years ago
Yep. I just now downloaded 1.1a and it works fine. I should have tried it 
when it first came out. Sorry about that.

Hurray! Now I can dump IE and have my office standardize on Mozilla! What a 
relief.

Thanks for all your good work!

Comment 12

16 years ago
cool. verifying.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.