Closed Bug 192163 Opened 22 years ago Closed 22 years ago

Button HTML tag submits the form even if the onclick event is history.back instead of form.submit

Categories

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

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 97829

People

(Reporter: treefrog, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130

I created a form that has a "preview" feature.  The first time the form is
submitted, the data entered is displayed on the next page.  At the end of this
second, "preview" form, there is an <input type="submit"> button and a <button
onclick="history.back()">  button.  When I click on the <button> button, it
actually submits the form rather than going back one page in the javascript history.

Reproducible: Always

Steps to Reproduce:
1. Create a form and submit it to a "preview" script.
2. Using your favorite CGI (I used PHP), process the form only enough to show
the data that was entered into the first form.
3. In the processed form display the results of the form and enter the data into
"hidden" form fields.
4.  within the <form></form> tags, put a <button> tag like this:
<button onClick="history.back();">Go Back and Edit</button>
5.  Click the button and the form will actually be submitted rather than go back.
Actual Results:  
The "preview" form was submitted rather than performing the "onclick" command.

Expected Results:  
It should have performed the javascript command to go back 1 page rather than
submitting the form.
THis one is 100% dupe of bug 188544 (button click also submit form), wich marked
as dupe of bug 97829. So I propose dupe to bug 97829.

I apologize for this dupe.  I searched the bug database and it didn't show up,
so I posted it.  Please forgive the trouble.

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