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

FORM submits to self loosing variables

LEGEND ,
Dec 10, 2006 Dec 10, 2006

Copy link to clipboard

Copied

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


TOPICS
Advanced techniques

Views

310

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
Community Expert ,
Dec 10, 2006 Dec 10, 2006

Copy link to clipboard

Copied

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.




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
LEGEND ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

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.
>
>
>
>
>
>


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
Advocate ,
Dec 11, 2006 Dec 11, 2006

Copy link to clipboard

Copied

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.

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
Community Expert ,
Dec 12, 2006 Dec 12, 2006

Copy link to clipboard

Copied

LATEST
Here's another idea. The if-block will always store the values of the fields in the currently submitted form.

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