Shaun Mccran

My digital playground


Firefox helpfully caching forms and their values

Whilst building a form recently I hit a real noob stumbling block. I was trying to set a select value to selected if the value had previously been submitted, something like this:

view plain print about
1<cfset variables.prefix = "Mr,Mrs,Ms,Miss,Dr">
2                <select name="title" size="1" class="form-select">
3                    <option value="">Please select from</option>
4                    <cfloop list="#variables.prefix#" index="variables.index" delimiters=",">
5                        <option value="#variables.index#" <cfif attributes.title EQ #variables.index#> selected="yes" </cfif>>#variables.index#</option>
6                    </cfloop>
7                </select>

Pretty straight forward, you'll all agree. The issue comes in where I had entered selected="selected". This isn't the correct code for a select option.

Handily Firefox will cache the form structure and form data, so that when you refresh the page it just loads up the cached version. This is great if you coded it correctly, otherwise it happily serves you up your coding errors again. So don't refresh your forms in testing.

Add ?test=1 or something to make the request a new URL.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Henry Ho's Gravatar For HTML 4.01 , just use 'selected' in <option>

For XHTML, use 'selected="selected"' in <option></option>

If you're using populating <select> from a query object, give cfselect a look. <cfselect query="qList" selected="1,3,5,7,9"/>
# Posted By Henry Ho | 14/12/2009 20:47
salmanonline's Gravatar That`s the reason Firefox is used by such a vast number of users. It has very few errors in comparison to IE[especially 6&7].
# Posted By salmanonline | 15/12/2015 15:24
free blogger themes's Gravatar your content seems quite easy and helpful to understand.
# Posted By free blogger themes | 16/12/2015 05:34
Katrina Kaif HD Wallpapers,Images Download 2015's Gravatar Nice tutorial post. In the beginning I had some issues with the coding but your tutorial helped me to solve the issue without any further problems. Thanks for sharing. Get Katrina Kaif HD Wallpapers,Images Download 2015 in 1080p Resolution. Katrina Kaif images download, Katrina Kaif wallpaper hd, Katrina Kaif photos hd from
# Posted By Katrina Kaif HD Wallpapers,Images Download 2015 | 19/12/2015 15:17
Gelenn Gooch's Gravatar Quality testing and reintegration testing is always great for all of us and in this we can make our life successful and developed. They should get the quality testing system on this website.
# Posted By Gelenn Gooch | 05/01/2016 00:01
mia khalifa hd wallpapers,pics,images,photos's Gravatar I am glad to seen this post. Thanks for this post.
<a href=" khalifa hd wallpapers,pics,images,photos</a>
# Posted By mia khalifa hd wallpapers,pics,images,photos | 09/01/2016 03:37
kajal agarwal hd wallpapers,pics,images,photos's Gravatar I am found more information to this site. Thanks for this post.
<a href=" agarwal hd wallpapers,pics,images,photos</a>
# Posted By kajal agarwal hd wallpapers,pics,images,photos | 09/01/2016 03:40
Back to top