• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Form values lost

Participant ,
Jan 30, 2007 Jan 30, 2007

Copy link to clipboard

Copied

I have a form with 10 questions. when the user clicks submit button the form fields are validated on a 2nd page.

If there are errors the user get an error message like this.

You must Answer Question 5 .
Please go back and correct. (user clicks here to go back) or uses the back button.

The problem is sometimes when the user goes back the values that they entered are gone.

I have dealt with this before by putting

CFHEADER NAME="cache-control" value=7200>

at the top of the form page.

But now I have a javascript calender on the form page and it appears to be overriding the
CFHEADER NAME="cache-control" value=7200>

So when the user returns to the form to fix the errors.....the form fields are blank.

Is there a way I can send the form fields that were submitted on the form back through the

Please go back and correct link

and repopulate the form.fields with the values passed in the url?

TOPICS
Advanced techniques

Views

481

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jan 30, 2007 Jan 30, 2007
URL variables are a possibility, but IMO kind of ugly.

Are session variables available to you? if so, i'd handle it like this:

1) on the form page, do a <cfparam> for each form field, setting the value to empty string and putting the vars into the session scope. e.g. <cfparam name="#session.formFirstName#" value="" type="string" />

2) on the form page, give each input a value that corresponds to the value you created using the cfparam. e.g. <input type="text" name="firstName" value="#session....

Votes

Translate

Translate
Guest
Jan 30, 2007 Jan 30, 2007

Copy link to clipboard

Copied

URL variables are a possibility, but IMO kind of ugly.

Are session variables available to you? if so, i'd handle it like this:

1) on the form page, do a <cfparam> for each form field, setting the value to empty string and putting the vars into the session scope. e.g. <cfparam name="#session.formFirstName#" value="" type="string" />

2) on the form page, give each input a value that corresponds to the value you created using the cfparam. e.g. <input type="text" name="firstName" value="#session.formFirstName#" />

3) on the action page, set each of the form values passed to a corresponding session variable. e.g. <cfset session.formFirstName = form.firstName />

don't do the validation/redirect back to the form until after all of the fields have been added to their corresponding session variables.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2007 Jan 31, 2007

Copy link to clipboard

Copied

Do the form validation on page 1 (use <cfif> <cfifelse> <cfelse> method to display error messages). If the validation is successful, then on to page 2, with your URL variables in tact.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 05, 2007 Feb 05, 2007

Copy link to clipboard

Copied

I have never validated forms with <cfif> <cfifelse> <cfelse> method

You wrote

"Do the form validation on page 1 (use <cfif> <cfifelse> <cfelse> method to display error messages). If the validation is successful, then on to page"

How do i do this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 06, 2007 Feb 06, 2007

Copy link to clipboard

Copied

LATEST
try clearing temporary internet files on the browser. this normally solves the problem of losing form data when you click the back button.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation