Read the latest web development and design tips at Fred Wu's new blog! :-)
Poke me on GitHub

If you ever have an HTML select that doesn’t want to default to the option you’ve added selected=”selected” to, it may not be a problem in your code. It may be due to Firefox’s behaviour.

Firefox seems to always default to the option selected by a user instead of the option that has the selected=”selected” tag – even on a page refresh (without even first POSTing the data)! Copy and paste the URL into another browser tab/window and it’ll most likely work fine… :)

Internet Explorer doesn’t have this problem (surprisingly).

  • Digg
  • DZone
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Related posts

Tags: ,

Comments Section

14 Responses to “”

Sidebar might be covered by comments ... consider it a feature! ;)
  1. 1

    Yup, it’s annoying. Clicking into the address bar and then hitting Enter is the easiest way to refresh the page without actually hitting refresh.

  2. 2

    Yeah. I’ve had this on FF3/Mac. That coupled with FF3′s over zealous caching make for plenty of ‘fun’ web dev!

  3. 3

    @both Tims – It’s not often we have something bad to say about Firefox, but this is one issue that seems to get me every now and then. The only other really bad thing I can think of is how FF3 (Windows) can hog memory in a really bad way once it’s been running for a while, but that’s for another post… :)

  4. 4

    I did some testing out of curiosity. It seems that if the requested file is a plain html (filename.html), both IE and Firefox cache the selected item. Once the file extension is changed to .php, IE changes the behaviour but Firefox does not.

    In MVC frameworks (at least in Kohana), since views are called upon controller requests, selected items get refreshed every time.

  5. 5

    @Fred – Thanks for the extensive testing ;)

    I was getting the issue in a CodeIgniter app, but I guess the main thing is for developers to not worry too much if they experience this behaviour in FF. Just as long as they don’t go madly changing code when it’s not really an issue ;)

  6. 6

    have same problem, but it don’t works to me.

  7. 7

    chubaka, feel free to post some code and we’ll see if we can help :)

  8. 8

    Thanks! Debugging this problem was driving me crazy until I happened upon your post.

  9. 9

    This Firefox feature is very annoying! The option selected by the user may well trigger an event and cause the page to change state via ajax or whatever so having it pre-selected is no use..

  10. 10

    Oh man, thank you so much for this. I’ve been racking my brain for over an hour over a few lines of code, and I found this solution after I deleted the entire thing to start over. xD Thanks so much, now I see why nothing was changing. :P

  11. 11

    FYI. I am experiencing the same problem with IE8. But it is happening when the HTML code is part of a PHP module.

  12. 12

    Thanks! You saved my day!

  13. 13

    The easiest way to overcome this is to add autocomplete=”off” to your select field. For example

    option 1
    option 2 selected </option

    I hope it solves the problem here :-)

  14. 14

    The easiest way to overcome this is to add autocomplete=”off” to your select field. For example

    option 1
    option 2 selected </option

    I hope it solves the problem here :-)
    Regards: G0g0l