Re: Values of disabled form elements not submitted

On Thu, 11 Dec 2003, Markus Ernst wrote:

> According to the HTML 4.0 specification values of form elements with the
> disabled control are not submitted with the form. I don't see a reason for
> this, as the only reason for the existence of a form element is to submit
> it's value. If the value is not needed it can also be displayed as text.

The observation often applies, but the idea is that a disabled control can
be switched to a normal control. For example, a text input field can be
set initially disabled, then enabled when a particular choice is made in
the form, making the field applicable.

> In an application there might be forms with elements that are active in some
> cases but inactive in others. Still it's important to display the whole form
> for consistence reasons, and still the value is needed.

Right, that's what I meant.

> The most consistent
> way of display is what UAs display when an element has the disabled control
> (greyed out display).

That's a bit debatable, but it's just a presentational issue.

> All workarounds are not satisfactory:
> - Javascript trickery does not work on non-Javascript browsers

Well, the wordings aside, that's an important point.

Usually a disabled field is meant to be an _optional_ field, and disabling
it is a way of telling the user that he is not meant to use the field.
Since there is no way but scripting to enabled the field and since the
field would presumably be relevant in _some_ situations, the current
approach is questionable. We set the field disabled in HTML, and then
maybe enable it in JavaScript. It would be much more logical and reliable
to use normal markup in HTML and set the field disabled in JavaScript.
That is, disable it only when the technology that may enable it later
is in use.

This would allow HTML to be simplified. No changes would be needed
elsewhere, except that the disabled property would need to be defined
separately in the DOM, not as taken from HTML attributes.

> - Readonly elements are not greyed out on many UAs which is confusing

Well, that's a different issue. Disabled and readonly are not the same
thing, though confusingly similar. And then there's the possibility of
setting display: none or visibility: hidden in CSS, or setting visual
properties like text and background color and border.

> For these reasons I suggest to change the specification of the disabled
> control in future versions of HTML/XHTML the way that the name/value pair of
> these elements are submitted with the form.

I don't see how that would solve the problem that a disabled field remains
disabled (i.e. cannot receive input). But it would change the meaning of
being disabled.

I think disabled should be removed as an HTML attribute, and it would
probably be best to do the same to readonly. It is true that readonly is
occasionally useful, but it basically lumps quite different things
together: what gets sent when the form is submitted, and what is visible
as part of the form. Readonly fields are normally used only in forms
generated by server side code, and in such code it should be trivial to
generate both a hidden field and a visible element with the same textual
content. (Or is this really an efficiency problem? I think applications
that depend on a large chunk of text being transmitted in a readonly
textarea are based on misunderstandings, but maybe I'm missing something.)

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

Received on Thursday, 11 December 2003 05:22:52 UTC