Solved

how do I pass a coldfusion variable to a cfselect bind attribute

Posted on 2009-04-09
6
1,392 Views
Last Modified: 2013-12-24
I have a cfselect tag like the following:

<cfselect name="patientfind"
    bind="cfc:subjects.subject_select({subject_name@keydown},39,1)"
      value="entityid"
    display="fullname"
      size="5"
      width="200"      />

I need to be able to replace the two last arguments (the 39 and 1) with coldfusion variables defined in the template that houses the cfselect statement. I have tried several different methods, from string concatenation to using ## around the variables names like this:
 
bind="cfc:subjects.subject_select({subject_name@keydown},#project_id#,"user_id#1)"

But none of these work. They all cause different javascript errors.

I figure that I am just missing something simple.

Your advice is greatly appreciated.

Tom
<cfselect name="patientfind"

    bind="cfc:subjects.subject_select({subject_name@keydown},39,1)"

	value="entityid"

    display="fullname" 

	size="5"

	width="200"	/>
 

<cfselect name="patientfind"

    bind="cfc:subjects.subject_select({subject_name@keydown},#project_id#,#user_id#)"

	value="entityid"

    display="fullname" 

	size="5"

	width="200"	/>

Open in new window

0
Comment
Question by:hoetom
6 Comments
 
LVL 19

Accepted Solution

by:
erikTsomik earned 500 total points
Comment Utility
just the numbers in local varibale
<cfset lLoc1=39>
<cfset lLoc2=1>

Then
bind="cfc:subjects.subject_select({subject_name@keydown},#lLoc1#,#lLoc2#)"

0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
You could always put the values in hidden fields,

<cfinput type="hidden" name="project_id" value="#project_id#">
<cfinput type="hidden" name="user_id" value="#user_id#">

... then use the the hidden fields as the last two values in the bind.
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
... Though using variables works fine for me

<cfselect..   cfc:mycfc.mymethod(#project_id#,#user_id#)">
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 27

Expert Comment

by:azadisaryev
Comment Utility
yes, just passing cf vars works fine. what you need to check is if your cfc function accepts them - does it have <cfargument> defined for each? are they required or not? are you passing them to the function in correct order?

also keep in mind that you can't pass a comma-delimited list as cf variable to your function via binding. you need to change list delimiters to something other than a comma.

Azadi
0
 

Author Comment

by:hoetom
Comment Utility
Thank you all for your advice.

I had tried wrapping the variable names in #, but it hadn't worked. I was getting by Firebug that I had an undefined variable. I played around with what I was passing and determined that I only got that error if the value of the variable that I was passing was a string.

In this case, I had to wrap the variable in a pair of single quotes, along with the #, or like this:

bind="cfc:subjects.subject_select({subject_name@keydown},#project_id#,'#user_id#')"

It is a long story on why my user_id is a string...

Thanks for your help.
Tom
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
> I had to wrap the variable in a pair of single quotes

Well, if it is either a string value or type,  then yes. Strings pretty much always need to be quoted ;-)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now