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 unique SKU, if you're wondering about application)
I've narrowed it down to this chunk of code, which throws an "Invalid Expression" error when I try and run it.
<cfif FORM["QTY_" & SKU] NEQ ''>
<div class="sopQty"><input type="number" min="0" name="QTY_#SKU#" value = "#FORM['QTY_' & SKU]#" /></div>
<cfelse>
<div class="sopQty"><input type="number" name="QTY_#SKU#" /></div>
</cfif>
The goal is to pass the value on from the previous page if there is one, else leave the field blank. I'm thinking there's some quirk of syntax in this case that I haven't been able to figure out. Error in block below:
Type: Template
Message: Invalid Expression
Tag: CFIF
Position Line=62; Column=17
Detail Bad Expression [#FORM['QTY_' & SKU])#]
Source
60: <div class="sopSearch"><p>#SearchAlias#</p></div> 61: <div class="sopPrice"><p>#ISBNupc#</p></div> 62: <cfif FORM["QTY_" & SKU] NEQ ''> 63: <div class="sopQty"><input type="number" min="0" name="QTY_#SKU#" value = "#FORM['QTY_' & SKU])#" /></div> 64: <cfelse>
^ Snippet from underlying CFML source
Any suggestions?