Link to home
Start Free TrialLog in
Avatar of jsimonuchc
jsimonuchcFlag for United States of America

asked on

Parse brackets in the URL string

Hi,

I was trying to figure out how to parse brackets in the URL string. I have a javascript program that serializes my data and passes the following URL string to my coldfusion page

http://hsecfs1/developmentdmz/mctr/sortAjax.cfm?item[]=1&item[]=2&item[]=3

Unfortunatley, I can't figure out how to pull the data.

<cfoutput>#url.item[]#</cfoutput> doesn't seem to work. Any advice would be appreciated. Thank you!
SOLUTION
Avatar of dagaz_de
dagaz_de

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dagaz_de
dagaz_de

Sorry the cfloop was not closed correct:

<cfoutput>#url.item#</cfoutput>

<cfloop list="#url.item#" index="i">

     <!--- Do something with i --->
    <cfoutput>#i#</cfoutput>
</cfloop>
Avatar of jsimonuchc

ASKER

No, I cannot remove the brackets (or I haven't figured out how to do it yet).
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
CFDUMP shows me a struct with the following contents:

ITEM[]       1,2,3
Awesome,  <cfset theValue = url["item[]"]> seems to work.
It gives me the values in a comma separated list.

perfect, glad it works
now you can loop over the list like i told you....

<cfset theValue = url["item[]"]>

<cfloop list="#theValue#" index="i">

     <!--- Do something with i --->
    <cfoutput>#i#</cfoutput>
</cfloop>