Closed Bug 379614 Opened 17 years ago Closed 3 years ago

form.submit() does not get executed when the button is clicked, the same works fine for the anchors

Categories

(Core :: DOM: Forms, defect, P5)

x86
Windows XP
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: shafi_363, Unassigned)

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3

In the button's onclick handler, execution of 'form.submit()' does not result into a full page refresh. I observed this using Firebug. 

But the same onclick handler if I attach to an anchor, form.submit()'s execution will result into a full page refresh. 

Reproducible: Always

Steps to Reproduce:
HTML Testcase

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Form Submit test case </TITLE>
<script type="text/javascript">

function doSubmit()
{
  alert("First Alert");
  document.forms[0].submit();
  alert("Second Alert");
}
</script>
</HEAD>

<BODY>
<form>
  <a id="anchor" onclick="doSubmit()" href="#">anchor</a>
  <button id="button" onclick="doSubmit()">button</button>
</form>
</BODY>
</HTML>



Actual Results:  
click on 'button' :
  1. 'First Alert' comes up
  2. 'Second Alert' comes up.
  3. Full page refresh happens

click on 'anchor'
  1. 'First Alert' comes up
  2. Full page refresh happens
  3. 'Second Alert' comes up.


Expected Results:  
clicking on both 'anchor' & 'button' should result Full page refresh to happen in between the alerts.
If 'document.forms[0].action =  document.forms[0].action' is placed after 'document.forms.submit()' in the doSubmit() method, then clicking 'anchor' & 'button' result in the correct behavior.
Attached file HTML test case
HTML test case
Assignee: nobody → general
Component: General → DOM
Keywords: testcase
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → Trunk
This is WORKSFORME on trunk.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → WORKSFORME
Hmm, or maybe not. But <a onclick> and <button onclick> seem to work similarly now.
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
please enable the status bar to see the difference. 

clicking on the 'anchor', results in the following order as expected.
1. Shows 'First Alert'
2. Page refresh in the status bar
3. Shows 'Second Alert'


But clicking on the button throws the 'First Alert' , then 'Second Alert' and then 'Page refresh in the status bar'.
If I modify the doSubmit method by placing an extra line 
'document.forms[0].action = document.forms[0].action', then click on anchor & link result in the same behavior.

function doSubmit()
{
  alert("First Alert");
  document.forms[0].submit();
  document.forms[0].action = document.forms[0].action;
  alert("Second Alert");
}
Assignee: general → nobody
QA Contact: ian → general
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Component: DOM: Core & HTML → DOM: Forms

I couldn't reproduce, I think this is not a vaild bug anymore. Feel free to file a new bug if you still encounter this.

Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: