Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser caching select tag state and ignoring selected="true"

Tags:

html

browser

I'm rendering a drop down box that contains a currently selected value using selected="true".

<select id="dropDown"> 
    <option selected="true" value="1">value2</option>
    <option value="2">value3</option>
    <option value="3">value4</option>
</select>

Initially the selected value corresponds to the selected="true", but if I play around with the drop down box and then refresh the page the selected="true" is ignored and the displayed value is the last one I chose. I tried using selected="selected" with the same results. Thanks for your help.

like image 299
Assaf Karmon Avatar asked Jan 09 '12 16:01

Assaf Karmon


People also ask

How do I stop HTML from caching?

Solution 1: While hitting the refresh web button of the browser, hold the Shift key (or press Shift+F5). This must tell the browser to fetch the page from the server even if the page is already in the browser's cache.

How do I force a browser to reload cached files?

To ensure you see the latest version of a site you need to clear the cache memory. This is done by doing a force refresh by pressing both control and F5 buttons simultaneously on your keyboard (depending on your browser). Most times a simple force cache refresh won't work and you need to clear the cache by hand.


1 Answers

Change your select field to <select id="dropDown" autocomplete="off">

like image 135
j08691 Avatar answered Oct 13 '22 01:10

j08691