Article
Disabled HTML form elements are not submitted
Somehow, I’ve made it this far* not knowing that disabled HTML form elements don’t get submitted with the form. Amazing.
Why I care
I’m keen on using the disabled attribute to indicate that a form field is well, disabled. We do this a few places in FeedBurner — you uncheck a box and it disables some form controls that are no longer relevant. It’s a nice way to illustrate cause and effect without concealing available fields.
Equivalent properties
There’s the readonly attribute, which is great except it doesn’t work for <select> elements.
And that’s about it. I cannot come up with any equivalent method for “disabling” HTML form elements while still submitting their value.
What do you know?
If you have an idea, send me an email. My address is jazer at this here domain.
* Exactly “how far” I’ve made it is certainly up for debate.
* * *
Update
Thanks to the many people who have emailed about this. The best solution (which I’d like to share at some point) is to create — via the same script that does the disabling — a duplicate hidden <input> element with the same value as the recently disabled field. And of course when you enable a field, likewise look — again, via script — for the hidden dupe and destroy or disable it.
Anyway, thanks again for the advice.