Skip to main content
April 7, 2010
Question

resetting form variables

  • April 7, 2010
  • 2 replies
  • 400 views

Hello All,


I am trying to do the following:


I have a web page which has all form variables populated. One such variable is current year. There is a link called 'previous year data' which upon clicking opens a


new page for the previous year and shows previous year stuff. This is done for comparing data between two years


When the user clicks on the 'previous year' link, am just replacing the form variable which stores the current year value


with the previous year value. Suppose I have the following variable:


<input type="hidden" name="hold_year">


initially it would have the current year, but I am populating with previous year, so the query that gets the data depending


on the year, uses the hold_year variable. But when I click on previous year link, the new window opens with previous year


data, but the old window upon navigation reflects data from previous year. is there a way that both windows shows their respective


data?

Message was edited by: funandlearning333

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
April 14, 2010

You could define two forms, and hold them in session scope. Do this just before you replace the form variable:

<cfset session.oldForm = structNew()>

<cfset session.oldForm= duplicate(form)>

Alternatively, you could replace the fields one by one, like this

<cfset session.oldForm.year = form.hold_year>

<cfset session.oldForm.id = form.id>

and so on.

Then, do precisely the same thing later on with the current values:

<cfset session.newForm = structNew()>

<cfset  session.newForm= duplicate(form)>

After that, you will have available, on every page, the two structs session.oldForm and session.newForm.

Inspiring
April 7, 2010

It sounds much more complicated than it needs to be.  Have you considered putting something on the form that allows the user to include of exclude the previous year and then presenting the information based on their preference?  From a useability perspective it has the advantage of having the 2 years on the same page so you don't have to keep switching windows.