4 Replies Latest reply on Feb 6, 2007 11:38 PM by beauars1

    Form values lost

    weezerboy Level 1
      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?

        • 1. Re: Form values lost
          Charlie Griefer Level 1
          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.
          • 2. Re: Form values lost
            Frosty88 Level 1
            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.
            • 3. Re: Form values lost
              weezerboy Level 1
              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?

              • 4. Re: Form values lost
                beauars1
                try clearing temporary internet files on the browser. this normally solves the problem of losing form data when you click the back button.