Wednesday 25 July 2007

Firefox - preselecting a Select Option

Firefox doesn't cope with

selected value='3'>Pineapple

If you load a page, select the option, then use View Selection Source - you find that Firefox comes up with:

selected='selected' value='3'>Pineapple

BUT if you then put that into your HTML, it ignores that too.

Answer: use selected='true'.

Simple, but it took me a while to find it. Hope this saves grief for someone else

POSTSCRIPT - further woes on a field that had an ID containing two underscores (not adjacent to each other: it was "bookMode_0none_1RequestForm") - where Firefox (1.5.0.12) preselected the LAST option whilst it happily reported coding that showed a previous option selected.

Replacing the second underscore with an alphanumeric character sorted the problem. (No problem with the two-underscore term for name - it was ID that was the issue). But it's spooky stuff - extract the code with View Selection Source and paste into a new document and Firefox is fine with the two underscores. Could it be related to the fact that the code is being served up by php? No time to experiment more.

No comments: