?
Solved

CF - Concatenate question

Posted on 2009-04-28
13
Medium Priority
?
256 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:wkolasa
13 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24252638
can you try this

#trim(getform.CFADMIN325)#
<cfset resourceNum =#trim(right(getform.CFADMIN325,3))#>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24252982
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])#
0
 

Author Comment

by:wkolasa
ID: 24254103
Agx,

First solution:  #getform['CFADMIN' & resourceNum][1]#  throws this error --

Element CFADMINRESOURCENUM is undefined in GETFORM.  
<input type="Text" name="#resourceNum#" value="#getform.CFADMINresourceNum#" 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.


0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 52

Expert Comment

by:_agx_
ID: 24254256
First, is getForm a query?

> <input type="Text" name="#resourceNum#" value="#getform.CFADMINresourceNum#" 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">
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24254292
Correction:
    <input type="Text" name="#resourceNum#" value="#getform['CFADMIN' & resourceNum][1]#" size="30">

Open in new window

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 24254300
> Solution two:   #evaluate(getform['CFADMIN' & resourceNum])# throws this erro --

Yes, I almost never use evaluate.  But here is an example that works:

      <cfoutput>#evaluate("getform.CFADMIN"& resourceNum)#</cfoutput>
0
 

Author Comment

by:wkolasa
ID: 24254308
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.

0
 

Author Comment

by:wkolasa
ID: 24254319
error created using this:  

<cfset eNum = 6>
<cfset textAreaName = "cf10o" & eNum>

#getform[textAreaName][getForm.currentRow]#
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24254525
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][getForm.currentRow]#
</cfoutput>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24254532
> You must be something different in your code.

    You must be _doing_ something different in your code ..
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24254544
... Though, as I mentioned it is more suitable for looping through a query:

     <cfoutput query="getForm">
           #getform['CFADMIN' & resourceNum][ currentRow ]#
     </cfoutput>


0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24257258
>> [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
0
 

Author Closing Comment

by:wkolasa
ID: 31575559
Thank you
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question