I have a table in a form with a loop around it that sets an index on all the name fields (form variables) that changes based on user input (user dictates how many tables get built). Once submitted, I take these variables and create a struct out of it. I know that a query object is already a struct, but I have to have each tables names unique, then put them into a struct which I can then rename to insert into the DB. My problem is how do I write this correctly and efficiently? I need to have a variable with a nested variable that is my index to make the name unique for each iteration through the loop. I have tried many combinations of pound signs and quotes and can't get it. If there is a better way to do this I am up for that too! dot notation
- cfset myStruct#i#=StructNew()>
- cfset myStruct#i#.ID#i#="#form.myVarA#i##"
- cfset myStruct#i#.s1#i#="#form.myVarB#i##"
- cfset myStruct#i#.s2#i#="#form.myVarC#i##"
associated array notation
- cfset myStruct#i#=StructNew()>
- cfset myStruct#i#[ID#i#]="#form.myVarA#i##"
- cfset myStruct#i#[s1#i#]="#form.myVarB#i##"
- cfset myStruct#i#[s2#i#]="#form.myVarC#i##"
Any help is greatly appreciated.