Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Should selected & disabled <option> elements be included when serialising a form?

Status
Not open for further replies.
Dec 8, 2003
17,047
GB
Can anyone tell me whether selected & disabled <option> elements should be included when serialising a form?

I thought the answer would come easily from checking out the behaviour of some JavaScript frameworks, yet they differ in their behaviour.

Prototype 1.7.0.0 does serialise them, but jQuery 1.7.2 does not. I've put together a test page here where you can see the results: [URL unfurl="true"]http://jsfiddle.net/CodeCouch/YR263/[/url]

I thought I'd refer to the WHATWG documentation on the FormData object, but it only talks about selected options or disabled options - never when an option is both selected and disabled.

I guess there's no "right" answer, and ultimately I should run with whichever behaviour suits my needs... but it would be nice to know what the general consensus is on this.

Thanks!

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[blue]@[/blue] Code Couch:
[blue]@[/blue] Twitter:
 
The behavior for them is pretty standard across the board for selected and disabled options at the same time.

While they start out selected, they can never be selected again if something else is selected.

So the question of whether or not to serialize becomes a question of whether it is still the selected option or not.

If something else has been selected, then I'd say no, don't serialize, as they are just a disabled item.

If they are still a selected option at the time, then yes serialize, as it becomes a required value.

Which brings us to the conclusion, that if they are both disabled and selected or rather disabled "BUT" selected, then they should be serialized.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top