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

cfset issue

Explorer ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

Hi,

I have a form with a text field. The name of the field is a reference to a structure held in
memory (session scope)

this is the example of the form field

<input type="text" name="session.source_wizard.getStep(5).data[1]['WEBADDONA'][3]['benefits'][8]['gbp_yr1']" value="2" size="5" maxlength="24">

now when the form is submitted i want to update the value for this key which is referenced by the name of the form field i.e

<cfloop collection="#form#" item="i">
<cfif left(i,7) eq "session">
<cfif len(attributes )>
<cfset "#evaluate(i)#" = "#form
#">
</cfif>
</cfif>
</cfloop>

The above does not seem to work for me. It does not update the structure. Can anyone please help me? Or tell me why this doesn't work?

Thanks
TOPICS
Advanced techniques

Views

370

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 ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

what exactly is attributes[ ]??? that should not work...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

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
Explorer ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

sorry i copied the code wrong. it should be

<cfloop collection="#form#" item="i">
<cfif left(i,7) eq "session">
<cfif len(form )>
<cfset "#evaluate(i)#" = "#form#">
</cfif>
</cfif>
</cfloop>

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 ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

Edited post - I think I misread your initial post. You want to pass the NAME of a variable as the name of a field and then update that variable with the form value, right?

How About:

<cfloop collection="#form#" item="item">
<cfif left(item,7) eq "session">
<cfif len(form[item])>
<cfset temp = SetVariable(item, form[item])>
</cfif>
</cfif>
</cfloop>

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 ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

Are you saying your field name is this entire string:
session.source_wizard.getStep(5).data[1]['WEBADDONA'][3]['benefits'][8]['g
bp_yr1']?

Wow, does that come through cleanly. If you <cfdump var="#form#"> on
the action page, do you actually have a field name with that string?
I'm not sure all those characters are allowed in form field names.

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 ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

You might be better off using 2 fields instead of one:

<input type="hidden" name="setField1_name" value="session.source_wizard.getStep(5).data[1]['WEBADDONA'][3]['benefits'][8]['gbp_yr1']">
<input type="text" name="setField1_value" value="2" size="5" maxlength="24">

And then on your processing page, you can loop over fields named "setField*" and:

<cfset temp = setVariable(FORM.setField1_name, Form.setField1_value)>

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 ,
Mar 07, 2007 Mar 07, 2007

Copy link to clipboard

Copied

LATEST
Ian Skinner wrote:
> Are you saying your field name is this entire string:
> session.source_wizard.getStep(5).data[1]['WEBADDONA'][3]['benefits'][8]['g
> bp_yr1']?
>
> Wow, does that come through cleanly. If you <cfdump var="#form#"> on
> the action page, do you actually have a field name with that string? I'm
> not sure all those characters are allowed in form field names.

i have tested it and it actually does come through without a problem.
the problem arises, however, when zubair is trying to set a cf var with
that name through <cfset "#evaluate(i)#" = "#form#">... cf rightfully
complains that it is not a valid name for a cf var since it contains all
sorts of illegal chars...

--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com

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