Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox 5 not using select="selected" value on page refresh, retaining old value

I've found a strange bug in Firefox 5 (I don't have access to 4 right now). But, I think it was probably working in Firefox 4 because I just got a new computer and I don't remember seeing this error before.

I have a couple of select boxes. The selected value is based on a session value that can change by some selects in a modal window. When I close the modal window and refresh the page, instead of updating the select boxes to the correctly selected value, it stays on the value originally chosen when the page first loaded. What's very strange is that when I look at the code in Firebug it shows the correctly selected value, but that is NOT the value the select box shows as selected! I've also run javascript and the selectedIndex is what I see in Firebug and correct, but it is NOT what I see selected.

If I do a hard refresh, I will see the correct value selected. I've tried to set the selectedIndex to the selectedIndex or some other value, but this will ONLY work on a hard refresh--even though I know the code is running because the alerts run. This code works fine in other browsers. Does anyone know of any workarounds?

 <select id="sportid" name="sportid">
      <option value="all">All</option>
      <option selected="selected" value="8">3 on 3 Ice Hockey</option>
      <option value="1">Basketball</option>
      <option value="4">Billiards</option>
      <option value="6">Broomball</option>
      <option value="7">Dodgeball</option>
      <option value="10">Field Hockey</option>
 </select>

So, Even though 3 on 3 Ice Hockey should be selected, and the html says is selected, I see Basketball--which was the previous selection.

Thanks! Ember

like image 584
ember Avatar asked Jul 27 '11 18:07

ember


1 Answers

Try to add autocomplete="off"

<select id="sportid" name="sportid" autocomplete="off">
like image 123
hadvig Avatar answered Nov 20 '22 12:11

hadvig