Page 1 of 1

Firefox not preselecting selects

Posted: Sat Mar 28, 2009 9:43 am
by matthijs
Did you know that Firefox does not preselect options in a select form element?

Code: Select all

 
        <select name="training_intensity" id="training_intensity" >
            <option  value="5" >Very hard</option>
            <option value="4" >Hard</option>
            <option  value="3" >Normal</option>
            <option value="2" >Easy</option>
            <option  selected="selected" value="1" >Recovery</option>
        </select>   
 
In any other browser the option Recovery is preselected. Not in Firefox 3 on Mac ....

(maybe I'm light years behind discovering this. But it was a real "WTF?" moment when I couldn't figure out why my code didn't work)

Re: Firefox not preselecting selects

Posted: Sat Mar 28, 2009 9:45 am
by Eran
That's very weird. It works in FF3 on windows

Re: Firefox not preselecting selects

Posted: Sat Mar 28, 2009 9:55 am
by matthijs
Wait. I discovered it has to do with Firefox's caching/remembering of form values. A soft refresh (ctrl-r) will still retain the previous preselect, even if I disable cache in the web dev toolbar.

Hitting shft-ctrl-r (a hard refresh) does preselects the right value.

Re: Firefox not preselecting selects

Posted: Sat Mar 28, 2009 9:57 am
by Bill H
Have you tried it with

Code: Select all

<option  value="1"  selected>Recovery</option>
 
Or, simply make it the first option in the list, which I believe is displayed if none if the following options is tagged as selected.

Re: Firefox not preselecting selects

Posted: Sat Mar 28, 2009 9:06 pm
by JAB Creations
Bill H wrote:Have you tried it with

Code: Select all

<option  value="1"  selected>Recovery</option>
 
That's invalid (X)HTML, an attribute can not simply exist by itself.

I've only run an x86 OS X on a second AMD system about a year ago to test OS X versions of browsers and in general the bugs all seemed cross-platform related.

If you reload a page it will select the option you had selected. If you GO to the page it'll select the default value. To go to the page you'll need to fix the go button of which I have posted a solution without the need for an extension for such a critical GUI component...
http://www.jabcreations.com/blog/firefo ... -go-button

Re: Firefox not preselecting selects

Posted: Sat Mar 28, 2009 11:31 pm
by Bill H
That's invalid (X)HTML, an attribute can not simply exist by itself.
I was merely suggesting that he try it to see what happened. I'm not a criminal that would actually do something like that.

Re: Firefox not preselecting selects

Posted: Sun Mar 29, 2009 3:13 am
by matthijs
As I posted it is an issue of the pre-filling of forms in Firefox and a hard refresh solves the issue. When posting a form and reshowing the problem doesn't exist. So for now the issue is solved. It was just a very weird moment when doing soft refreshes didn't do what I expected. Ctrl-r is such a wired shortcut, I hit it before even thinking about it. (which does cause problems in the rare cases I open up Windows, I keep hitting inappropriate shortcuts..)

And of course it's too bad this is another issue that differs between browsers (please, get together and work on those standards!)

Re: Firefox not preselecting selects

Posted: Sun Mar 29, 2009 2:16 pm
by josh
FF has a "feature" that sometimes if you've been working with a form and use the back button to return to it, the last _user_ selected option will remain active, even upon page refresh. If you close the tab and re-key the URL directly it should revert to the programmer preselected option ( or if you use firebug you can click the element and look at your markup to see which element would have been selected )