Copy link to clipboard
Copied
Hi
I have the following...
<Cfloop from 1 to 100 index i>
<cfif isDefined ('FORM.JACKET#i#')>
<cfset jacketsize = #FORM.JACKET#i##>
</cfif>
</cfloop>
I need to know how to get the correct value from #FORM.JACKET#i##
Can anybody assist?
thank you
Delon
form["jacket" & i]
Copy link to clipboard
Copied
form["jacket" & i]
Copy link to clipboard
Copied
short and sweet!
thank you.
Copy link to clipboard
Copied
In the context of an HTML incoming data-stream (i.e. FORM), the data will always be "flat." Therefore, repeating values must be given unique names such as "JACKET18," which you do when building your code. It is perfectly acceptable thereafter to loop through "all possible values," checking that each one does or doesn't exist, as has been shown. Browsers vary in their handling of empty-fields: some browsers include them in the stream while others do not.
Outside of the context of an HTML data-stream, though, in the general sense any element of a Struct may be any sort of complex data-type you care to invent... array, another structure... or a simple data-value such as the numeral "2." myStruct.jacket could be an array of "jacket description" structures, each one containing who-knows-what.