Public Service Announcement - Firefox Caches Select Box State

Remember that the Firefox Browser caches the selected position on Select Boxes. I am not sure how to turn this feature off.

This means that if you select an option on a select box, and refresh, firefox will remember your select box index position. I've noticed the same behaviour on checkboxes and radio buttons, so be aware when debugging.

Heuristically speaking, I like the function, especially when filling out long involved forms. It is however, a complete pain in my MULE when I am debugging applications and can't figure out why the box isn't selected to the expected option.



Pressing CTRL+F5 redraws everything sans state.

Comments
It actually caches all the form variables. The solution is so simple I hate to admit how hard it was for me to find a solution to this. (Google didn't help, so blogging this is great... thanks for helping others find the answer to this with some humility on your part!

Answer... in the onload function of your page... or using your favorite AJAX library you you access the form you want to refresh. Now there is a second issue that you may not know of... but let's deal with the first solution.

document.getElementById('myFormId').reset();

Now for the secondary issue. Not all browsers create the submit or reset functions if you put a reset or submit button on the page. If those buttons are on the page then you run the click() function on the buttons. It will work the same that way as the above solution.
# Posted By John Farrar | 9/15/07 9:08 PM
like IE, FireFox has a hard refresh. Just hold down the shift key and hit the refresh icon or F5 and it reload everything.
# Posted By tony petruzzi | 9/15/07 10:30 PM
It's pretty easier to avoid

<form autocomplete="off"></form>
# Posted By zac spitzer | 9/16/07 12:02 AM
I'm with Tony P, shift and refresh... this has been around since Netscape 3 and ie 3 and is now used by all browsers.

don't use autocomplete="off" for production, it will tick people like me off. The new mozilla browsers re-introduced this as it was introduced, then removed from netscape in version 4.x

Its really handy during testing and development so you don't have to re-type your test data!!
# Posted By Chris Dawes | 9/16/07 10:47 PM
that's true, but there is the chance for data corruption with that approach

personally, i really like the form to always reflect the values the application is setting...

otherwise the caching can overwrite existing values that have been changed by someone else..not so good..
# Posted By zac spitzer | 9/16/07 10:57 PM
Man I was becoming completely crazy with my webpages dynamically generated by my embedded webserver. I completely missed the fact that it was a cache problem, it worked perfectly with IE7.

The autocomplete trick did the job perfectly, thanks for sharing this.

I admit it's a very convenient "feature" especially with long text fields, but it got me crazy.

Cheers!
# Posted By mielpops | 7/10/08 10:11 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.001. Contact Blog Owner