|
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:
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.
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"/>
<a href="http://www.picsnimages.com/mia-khalifa-pics.html&q... khalifa hd wallpapers,pics,images,photos</a>
<a href="http://directtutorials.com/kajal-agarwal-images-do... agarwal hd wallpapers,pics,images,photos</a>