简体   繁体   English

Firefox 5在页面刷新时不使用select =“selected”值,保留旧值

[英]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). 我在Firefox 5中发现了一个奇怪的错误(我现在无法访问4)。 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. 但是,我认为它可能在Firefox 4中工作,因为我刚买了一台新电脑,我不记得以前看过这个错误了。

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! 非常奇怪的是,当我查看Firebug中的代码时,它会显示正确选择的值,但这不是选择框显示为选中的值! I've also run javascript and the selectedIndex is what I see in Firebug and correct, but it is NOT what I see selected. 我也运行javascript,selectedIndex是我在Firebug中看到的并且正确,但它不是我看到的选择。

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. 我已经尝试将selectedIndex设置为selectedIndex或其他一些值,但这只会在硬刷新时起作用 - 即使我知道代码正在运行,因为警报会运行。 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. 所以,即使选择3对3冰上曲棍球,并选择html说,我看到篮球 - 这是之前的选择。

Thanks! 谢谢! Ember

尝试添加autocomplete =“off”

<select id="sportid" name="sportid" autocomplete="off">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM