Closed Bug 247026 Opened 20 years ago Closed 20 years ago

Function submit() is undefined in forms. Calling submit() doesn't post the form.

Categories

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

x86
All
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 247745

People

(Reporter: bugzilla.mozilla, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040614 Firefox/0.9

When calling submit() in a form the form is not submitted. This warning shows in
the JavaScript console: "submit is undefined". Also this.submit() doesn't work:
"this.submit is not a function". It does work in older versions of Firefox (and
Mozilla).

Example code:

<form action="/" method="post">
<table>
	<tr>
		<td onClick="submit();">Click here</td>
	</tr>
</table>
</form>

Reproducible: Always
Steps to Reproduce:
1. Open a page containing the example code
2. Click on 'click here'
3. 

Actual Results:  
Form is not submitted

Expected Results:  
Form should be submitted

Tested on two computers, both with Win 2000. Many sites use the submit()
function, so this should really be fixed soon.
Attached file Reporter's testcase.
I would think this is INVALID, but this indeed worked in Mozilla1.6 (for some
kind of IE compatibility reason?).

This doesn't work in Opera7.23 by the way, so you could better use the dom:
document.forms[0].submit() or something like that.
> so you could better use the dom:
> document.forms[0].submit() or something like that.

Sometimes, when you have more than one form on a dynamically generated page, you
don't know in what form you are (forms[0],[1],[2] or whatever). Of course you
can build a script to print the right forms[n], but not every webmaster will do
that. 
Component: General → DOM
OS: Windows 2000 → All
Product: Firefox → Browser
Version: unspecified → Trunk
Assignee: firefox → general
QA Contact: firefox.general → ian
(In reply to comment #1)
> This doesn't work in Opera7.23 by the way, so you could better use the dom:
> document.forms[0].submit() or something like that.

It does work in Opera 7.51 Final (for Linux). I don't know if 'submit()' is 100%
valid JavaScript, but I think 'this.submit()' is. Does that work in Opera 7.23?

*** This bug has been marked as a duplicate of 247745 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: