Closed Bug 143440 Opened 22 years ago Closed 22 years ago

Submit buttons do not submit their values when submit() is called

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: harunaga, Assigned: john)

References

()

Details

<input type="image"> submited by JavaScript doesn't send coordinates (x,y)
on Mozilla 1.0 RC1 and later.

document.mainForm.submit();
document.forms[0].submit();
document.getElementById("mainForm").submit();
fail all on 2002050603/Mac OS 9.2 and others.
On 0.9.9/Mac, these work.

This is similar to Bug 122238, but this is a problem of JavaScript/DOM.
If not using JavaScript, there is no problem.

And when displaying document.forms['mainForm'].elements[II].name/type,
Mac IE 5.1.4 shows like blow:

-----
document.forms['mainForm'].elements.length=5 
document.getElementsByTagName('input').length=5 
II=0,NAME=c1,TYPE=image 
II=1,NAME=c2,TYPE=image 
II=2,NAME=c3,TYPE=image 
II=3,NAME=c4,TYPE=image 
II=4,NAME=xxx1,TYPE=button 
-----

but Mozilla shows:
-----
document.forms['mainForm'].elements.length=1
document.getElementsByTagName('input').length=5
II=0,NAME=xxx1,TYPE=button 
-----

Is it OK?
IE/Windows does not have <input type="image"> in form.elements, so neither do
we, otherwise a number of pages breaks.

To jkeiser, but there's something I don't understand here...  The form is _not_
submitted via the image input.  It's submitted via the submit() method on the
form.  So I really fail to see a reason to send the coordinates (the submit()
method simply has no coordinates associated with it).

If it "worked" before, I feel that was a bug.
Assignee: rogerl → jkeiser
Component: JavaScript Engine → Form Submission
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
Um, anytime you call submit() with JS it will *not* send x and y.  input
type=image is a submit button.  You will notice that input type=submit does not
send its value unless you click it (JS will not send it).  Same with input
type=image.

The issue you are seeing is trickier but still invalid.  You do not need to call
submit() from within the JS handler for an image input.  input type=image is a
submit button and as such will submit on its own.  The reason this worked before
was that we were not catching double submit.  The JS was submitting *and* the
input type=image was submitting, which could cause people big problems.  Now we
take the first submit only, which in this case is the JS.

Mac IE puts the images into the array???  That is good to know, but many pages
are written assuming input type=image is not in the array.  Perhaps at some
point we can put them in quirks mode.  File a bug if this is something you want.
 But realize that if you write a page assuming input type=image is in the array
Windows IE will not work with it.
Setting default QA for component -
QA Contact: pschwartau → vladimire
Yes, Windows IE 6.0 doesn't put the images into the array too,
but *send* x/y by submit().
Please try the URL above on Windows IE, and click image area,
and watch the URL bar changing from
http://www.t3.rim.or.jp/~harunaga/test/form-submit.html
to
http://www.t3.rim.or.jp/~harunaga/test/form-submit.html?c1.x=27&c1.y=6 etc.
QA Contact: vladimire → pschwartau
OK, there is an ambiguity in the spec which could indicate, by a certain
reading, that submit() should submit the value of the currently-being-clicked
control.  This can be tested in IE with the code:

<html><body><form name=mainform><input type=submit name=a value=foo
onClick="document.mainform.submit(); return false;"></form></body></html>

If you would be so kind as to test on IE (I am in Linux right now) that would be
great, thanks.  If it submits with a=foo then IE works this way.  If so, I think
this bug is valid and would create the behavior you are looking for.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Summary: <input type=image> submited by JavaScript doesn't send x/y → Submit buttons do not submit their values when submit() is called
Setting default QA for component -
QA Contact: pschwartau → vladimire
I tested the code above on IE 6.0/Win98SE.
<input type=submit name=a value=foo onClick="document.mainform.submit(); return
false;">
doesn't work.
<input type=submit name=a value=foo onClick="document.mainform.submit();">
work.

And
<input type="image" onClick="document.mainForm.submit()" ...>
work, but
<input type="image" onClick="document.mainForm.submit();return false;" ...>
doesn't work too.

I think this bug is invalid.
Thank you.
Tested on IE5/Solaris as well, and adding the "return false" keeps the input
element's name from being submitted.

Marking invalid.
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago22 years ago
Resolution: --- → INVALID
verifying
Status: RESOLVED → VERIFIED
*** Bug 163742 has been marked as a duplicate of this bug. ***
Chuck, I think this is invalid.
But recently, it seems that an enhancement in this case was assigned.
See Bug 138957.
Invalid bug
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.