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

loop through post variables?

New Here ,
Jul 10, 2008 Jul 10, 2008
I'm trying to make my own viewstate setup (I'm a .NET guy trying to work on a CF site for a client). Is there a way I can cycle through all the available post variables when a form is submitted? I want to capture these and put them into a struct which will then be saved to the session, from which I can grab or modify fields as I need.

I know I can grab them individually, such as FORM.myinputfield, but how can I blindly cycle through them and put them into a struct? Thanks!

Ryan
624
Translate
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

LEGEND , Jul 10, 2008 Jul 10, 2008
rpeters1983 wrote:
>
> I know I can grab them individually, such as FORM.myinputfield, but how can I
> blindly cycle through them and put them into a struct? Thanks!
>
> Ryan
>

Here is how to take the FROM structure and put it into a SESSION
structure for persistent across request. It should be easy to follow
through.

<cfset session.myFormData = form>

The form data is already a structure and can be handled exactly like any
structure you create.

An Examples:

<cfloop collection="#form#...
Translate
LEGEND ,
Jul 10, 2008 Jul 10, 2008
rpeters1983 wrote:
>
> I know I can grab them individually, such as FORM.myinputfield, but how can I
> blindly cycle through them and put them into a struct? Thanks!
>
> Ryan
>

Here is how to take the FROM structure and put it into a SESSION
structure for persistent across request. It should be easy to follow
through.

<cfset session.myFormData = form>

The form data is already a structure and can be handled exactly like any
structure you create.

An Examples:

<cfloop collection="#form#" item="field">
#field# contains the value of #form[field]#
</cfloop>


Translate
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 ,
Jul 10, 2008 Jul 10, 2008
OK, I spoke too soon. I was able to get it to cycle through the loop. Now I'm trying to find out how to save that to a struct and then to a session variable. Do I have to use WDDX? Thanks again.
Translate
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 ,
Jul 10, 2008 Jul 10, 2008
rpeters1983 wrote:
> OK, I spoke too soon. I was able to get it to cycle through the loop. Now I'm trying to find out how to save that to a struct and then to a session variable. Do I have to use WDDX? Thanks again.

Not of you follow the suggestions in my previous post.
Translate
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 ,
Jul 11, 2008 Jul 11, 2008
LATEST
quote:

Originally posted by: Newsgroup User
rpeters1983 wrote:
> OK, I spoke too soon. I was able to get it to cycle through the loop. Now I'm trying to find out how to save that to a struct and then to a session variable. Do I have to use WDDX? Thanks again.

Not of you follow the suggestions in my previous post.



Your answer is correct. I posted my followup before I noticed your post. Thanks.

Translate
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