wkolasa
asked on
CF - Concatenate question
Hi,
I have this: #trim(getform.CFADMIN325)#
I want to use this variable: <cfset resourceNum = 325> to replace the 325 number above...
How would I write this out: #getform.CFADMIN [variable.resourceNum]#
I tried this but it didn't work: #getform['CFADMIN' & resourceNum]#
Thanks for your help!
-Wendi
I have this: #trim(getform.CFADMIN325)#
I want to use this variable: <cfset resourceNum = 325> to replace the 325 number above...
How would I write this out: #getform.CFADMIN [variable.resourceNum]#
I tried this but it didn't work: #getform['CFADMIN' & resourceNum]#
Thanks for your help!
-Wendi
If "getForm" is a query, you must supply a rownumber as well:
Example:
#getform['CFADMIN' & resourceNum][1]#
... Or if you are looping through a query:
<cfoutput query="getForm">
#getform['CFADMIN' & resourceNum][ currentRow ]#
</cfoutput>
Another, but less elegant and performant option is to use Evaluate(...) .
#evaluate(getform['CFADMIN ' & resourceNum])#
Example:
#getform['CFADMIN' & resourceNum][1]#
... Or if you are looping through a query:
<cfoutput query="getForm">
#getform['CFADMIN' & resourceNum][ currentRow ]#
</cfoutput>
Another, but less elegant and performant option is to use Evaluate(...) .
#evaluate(getform['CFADMIN
ASKER
Agx,
First solution: #getform['CFADMIN' & resourceNum][1]# throws this error --
Element CFADMINRESOURCENUM is undefined in GETFORM.
<input type="Text" name="#resourceNum#" value="#getform.CFADMINres ourceNum#" size="30">
It's not evaluating the variable (<cfset resourceNum = 325>
Solution two: #evaluate(getform['CFADMIN ' & resourceNum])# throws this erro --
Complex object types cannot be converted to simple values.
First solution: #getform['CFADMIN' & resourceNum][1]# throws this error --
Element CFADMINRESOURCENUM is undefined in GETFORM.
<input type="Text" name="#resourceNum#" value="#getform.CFADMINres
It's not evaluating the variable (<cfset resourceNum = 325>
Solution two: #evaluate(getform['CFADMIN
Complex object types cannot be converted to simple values.
First, is getForm a query?
> <input type="Text" name="#resourceNum#" value="#getform.CFADMINres ourceNum#" size="30">
> It's not evaluating the variable (<cfset resourceNum = 325>
That is different than what I posted. It would be more like this:
<input type="Text" name="#resourceNum#" value="##getform['CFADMIN' & resourceNum][1]#" size="30">
> <input type="Text" name="#resourceNum#" value="#getform.CFADMINres
> It's not evaluating the variable (<cfset resourceNum = 325>
That is different than what I posted. It would be more like this:
<input type="Text" name="#resourceNum#" value="##getform['CFADMIN'
Correction:
<input type="Text" name="#resourceNum#" value="#getform['CFADMIN' & resourceNum][1]#" size="30">
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes, getForm is a query. If I referenced the row I get the error:
[NA_SPO: coldfusion.sql.QueryColumn @f2fcb7] ] is not indexable by cf10o6
cf10o6 is one of the field names.
[NA_SPO: coldfusion.sql.QueryColumn
cf10o6 is one of the field names.
ASKER
error created using this:
<cfset eNum = 6>
<cfset textAreaName = "cf10o" & eNum>
#getform[textAreaName][get Form.curre ntRow]#
<cfset eNum = 6>
<cfset textAreaName = "cf10o" & eNum>
#getform[textAreaName][get
You must be something different in your code, because that works perfectly with a sample query.
<cfset getForm = QueryNew("cf10o6")>
<cfset queryAddRow(getForm, 1)>
<cfset querySetCell(getForm, "cf10o6", "See this test value? ...", 1)>
<cfset eNum = 6>
<cfset textAreaName = "cf10o" & eNum>
<cfoutput>
#getform[textAreaName][get Form.curre ntRow]#
</cfoutput>
<cfset getForm = QueryNew("cf10o6")>
<cfset queryAddRow(getForm, 1)>
<cfset querySetCell(getForm, "cf10o6", "See this test value? ...", 1)>
<cfset eNum = 6>
<cfset textAreaName = "cf10o" & eNum>
<cfoutput>
#getform[textAreaName][get
</cfoutput>
> You must be something different in your code.
You must be _doing_ something different in your code ..
You must be _doing_ something different in your code ..
... Though, as I mentioned it is more suitable for looping through a query:
<cfoutput query="getForm">
#getform['CFADMIN' & resourceNum][ currentRow ]#
</cfoutput>
<cfoutput query="getForm">
#getform['CFADMIN' & resourceNum][ currentRow ]#
</cfoutput>
>> [NA_SPO: coldfusion.sql.QueryColumn @f2fcb7] ] is not indexable by cf10o6
irrc, such error is thrown when the value of the field is NULL...
Azadi
irrc, such error is thrown when the value of the field is NULL...
Azadi
ASKER
Thank you
#trim(getform.CFADMIN325)#
<cfset resourceNum =#trim(right(getform.CFADM