#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    5
    Rep Power
    0

    passing array in hidden var


    <cfoutput>
    <cfloop collection="#session.cart#" item="i">
    <cfset name="#session.cart[2]#">
    <input type="hidden" name="name" value="#name#">

    </cfloop>

    currently I use the field to send to another page, but only prints once.

    <cfoutput>
    #name#
    </cfoutput>

    I think I need a cfloop or for loop but not sure how to implement
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,278
    Rep Power
    968
    One option is to dynamically name each hidden form field. Right now all of your form fileds would be named "name" which will screw things up.

    Another option is to translate the array into XML using the CFWDDX tag, and then pass the WDDX-formatted string in the hidden form field. Then on the next page you can use CFWDDX again to translate the XML back into an array.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Washington DC, USA
    Posts
    156
    Rep Power
    14
    You may also need to further format the WDDX using the ToBase64() function since the WDDX packet may not pass properly in a hidden form field.

IMN logo majestic logo threadwatch logo seochat tools logo