We are on CF9. I have a form that has multiple bound cfselect fields. If I submit the form and then go back using the browser's back button, all the bound cfselect fields are set back to their initial state. I have tried used preserveData = "yes" in eth cfform tag and set selected to the field name but this does not seem to work.
Is there a way to achieve this? Thanks.
<cfform id="form1" name="form1" action="majormarketAction.cfm?action=AddRecord" preserveData="yes" method="post">
<table border="0" cellpadding="4" cellspacing="0" width="480" align="center" class="FormTable">
<td style="padding-left:8px;" width="25%" valign="top"><strong>Market</strong><br />
<td valign="top" colspan="2"><strong>Customer</strong><br />
go back using the browser's back button
UNLESS you have configured YOUR browser to ALWAYS request new data from the server when you hit the back button -- OR your web site has requested the browser to do so. The browser is going to ITS OWN CACHE and showing what it previously downloaded, including the state of all form controls.
In other words, this is most likely a BROWSER issue, NOT a server issue.
I have found that a SESSION variable works very well in forms that potentially need to use the back button, or even refresh. If you submit the form the action page can set a SESSION variable for you. Then if the user hits back, you can test for the existence of a SESSION variable, if it exists, it's populated, if not, it comes up blank. You can even set the initial variable as a SESSION variable and forget the testing piece.
Having played with html and "hidden" values, a SESSION variable is a very handy piece of code.