4 Replies Latest reply on Dec 12, 2006 7:24 AM by BKBK

    FORM submits to self loosing variables

    Level 7
      I have variables set in the head of my template that are being passed from a
      form on page 1. The variables show up on page 2 just fine. However, page 2
      has shopping cart items and submits to itself. When it does this I loose all
      the passed variables from page 1 since they are being set to
      FORM.variablename. The form looses the variable on submit.

      I did not create page 1 or page 2 just trying to do some mods to the pages.
      My question is, how can I get page 2 to "keep" my variables on submit of
      each item in the cart?

      Kim


        • 1. Re: FORM submits to self loosing variables
          BKBK Adobe Community Professional & MVP
          Do something like this in a form field in page 2

          <cfoutput>
          <input type="text" name="var1_in_page2" value='#form.var1_from_page1#' >
          <input type="text" name="var2_in_page2" value='#form.var2_from_page1#' >
          </cfoutput>

          Then you will not lose the values from the form in page 1 when page 2 submits to itself.




          • 2. Re: FORM submits to self loosing variables
            Level 7
            Yes, I guess I could do that. I was just looking for something else. There
            are so many variables already being passed to the second page. But it looks
            like that may be the only way. Then would they have to be passed with each
            "add to cart" item.

            Kim
            "BKBK" <webforumsuser@macromedia.com> wrote in message
            news:eliga6$qh0$1@forums.macromedia.com...
            > Do something like this in a form field in page 2
            >
            > <cfoutput>
            > <input type="text" name="var1_in_page2" value='#form.var1_from_page1#' >
            > <input type="text" name="var2_in_page2" value='#form.var2_from_page1#' >
            > </cfoutput>
            >
            > Then you will not lose the values from the form in page 1 when page 2
            > submits
            > to itself.
            >
            >
            >
            >
            >
            >


            • 3. Re: FORM submits to self loosing variables
              insuractive Level 3
              I'm thinking the easiest thing to do would be to do what BKBK suggested and just pass the variables as a hidden form field. If you didn't want to write out all those <input> fields, you could loop over the FORM collection and generate the hidden Page1 form fields dynamically. You would just have to make sure to exclude the Form.FieldNames key, as well as any field names from the page2 form. Otherwise, you might wind up with duplicate fields if page 2 posted to itself - which would give you comma delimited values.

              Otherwise, you could experiment with Session or Client variables. Though, those are problematic with all the browser and security settings out here.

              In my opinion, You're best off with the hidden form field solution.
              • 4. FORM submits to self loosing variables
                BKBK Adobe Community Professional & MVP
                Here's another idea. The if-block will always store the values of the fields in the currently submitted form.