Solved

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

Posted on 2009-04-09
6
1,486 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 19

Accepted Solution

by:
erikTsomik earned 500 total points
ID: 24111849
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_
ID: 24111897
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_
ID: 24111963
... Though using variables works fine for me

<cfselect..   cfc:mycfc.mymethod(#project_id#,#user_id#)">
0
Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
LVL 27

Expert Comment

by:azadisaryev
ID: 24112809
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
ID: 24112880
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_
ID: 24113043
> 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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to Eclipse 16 154
Change local server setting in php 6 118
ip / url redirect 13 76
what does http://website.whatever/robots.txt do and what it means? 3 52
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

710 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