Closed Bug 111040 Opened 24 years ago Closed 24 years ago

Forms lose values when disabled

Categories

(Core :: Layout: Form Controls, defect)

x86
Windows 2000
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: phlegmatics, Assigned: john)

Details

(Keywords: dataloss)

Attachments

(1 file)

From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461) BuildID: Gecko/20011118 I'm trying to make is so that onsubmit on a form all of the form buttons are disabled, this will prevent the user from submitting the same form numerous times if there is lag. Reproducible: Always Steps to Reproduce: =====begin disable.html===== <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script> function disable_buttons(){ for(y=0;y<document.formX.length;y++){ document.formX.elements[y].disabled=!document.formX.elements [y].disabled; } } </script> </head> <body bgcolor="#FFFFFF" text="#000000"> <form name="formX" method="post" action="printme2.asp" onsubmit="javascript:disable_buttons();"> <p> <input type="text" name="answer"> </p> <p> <input type="radio" name="radio" value="ON"> </p> <p> <input type="hidden" name="hidden" value="ThisIsHidden"> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> </body> </html> =====end disable.html===== =====begin printme2.asp===== <%@ Language=VBScript %> <html> <head> <title>Untitled</title> </head> <body> These are the fields:<br> <% Response.write Request.Form("answer") & "<br>" &_ Request.Form("radio") & "<br>" &_ Request.Form("hidden") & "<br>" &_ Request.Form("Submit") & "<br>" %> </body> </html> =====end printme2.asp===== Actual Results: nothing Expected Results: all form vars should be printed This has nothing to do with the fact that it's ASP. This has been tried with various languages, and this same code works on Opera. Seems simple enough that it should work for the desired effect.
reassigning
Assignee: rods → jkeiser
Keywords: dataloss
Disabled controls should not submit, per the spec. Spec: http://www.w3.org/TR/html401/interact/forms.html#h-17.12.1 --------------- ... * Disabled controls cannot be successful. ... In this example, the INPUT element is disabled. Therefore, it cannot receive user input nor will its value be submitted with the form. <INPUT disabled name="fred" value="stone"> ----------------
Status: UNCONFIRMED → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
See the problem is that I submit BEFORE I disable. And if it IS the case that disabled forms don't submit, they do. If I change the even handler from onsubmit to onclick (on the submit button), and call disable_buttons(), with a javascript form.submit(), they the values go through. So...one of these methods shouldn't work, i'd prefer that they both did :)
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Severity: critical → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
The onSubmit handler runs just *before* submission (many people use this for validation). Thus your not seeing values there is normal. It would be unsettling if the onClick handler on the submit button was disabling the controls and submitting the values, but I am not seeing this. I will attach a testcase shortly, could you please try and it and see if you can determine why your test is showing up different? I agree that it sucks that there is no *easy* way to disable a control and still submit the value. But changing standard behavior like this so late in the game would totally destroy existing applications that rely on those values not submitting. one thing you can do is re-enable the control just before submission. Or you can try READONLY, I don't know if that's a standard attribute though.
Attached file Testcase
Note that I have tried this with POST as well as GET and it also works as expected there.
Oh, some explanation: these are GET requests, so you should see the elements show up in the URL bar after the questionmark. They do not show up in either test (as expected), and if you never call the disabler, they do show up on the URL bar.
Behavior fits spec. Closing. Reopen if you think this is an error, but explain please :)
Status: NEW → RESOLVED
Closed: 24 years ago24 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: