Attempting to use squarebracket notation to reference a dynamic variable. (I\'m looping through a set of product created by a query, creating fields for each tied to their uniqu
Below is also possible (and wont cause an error if the key is not defined).
<cfset key = "QTY_" & sku/>
<cfif structKeyExists(form, key) && len(form[key])>
<!--- do something --->
</cfif>
This is just an example,because I do not know where you are setting your variables, but try something like the following on your action page:
<cfset SKU = "123">
<cfset dynamic_Var = "QTY_" & variables.SKU>
<cfif IsDefined("form[dynamic_Var]")>
<cfoutput>#form[dynamic_Var]#</cfoutput>
<cfelse>
fail
</cfif>
Here is the submitting form:
<form name="test" action="test.cfm">
<input type="text" name="QTY_123" value="test">
<input type="submit" name="submit" value="submit">
</form>