6 Replies Latest reply on Mar 7, 2007 11:44 PM by Newsgroup_User

    cfset issue

    zubair
      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
        • 1. Re: cfset issue
          Level 7
          what exactly is attributes[ ]??? that should not work...

          --

          Azadi Saryev
          Sabai-dee.com
          http://www.sabai-dee.com
          • 2. Re: cfset issue
            zubair Level 1
            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>
            • 3. cfset issue
              insuractive Level 3
              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>
              • 4. Re: cfset issue
                Level 7
                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.
                • 5. Re: cfset issue
                  insuractive Level 3
                  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)>
                  • 6. Re: cfset issue
                    Level 7
                    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