• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

cfselect display attribute

I have a cfselect:

<cfselect query="getStaff" value="StaffID" display="FirstName"  name="preparedby"></cfselect>

Is there a way to have the display show the firstname and lastname together, as in display="FirstName & LastName" (which doesn't work, btw)?
0
David Williamson
Asked:
David Williamson
3 Solutions
 
pinaldaveCommented:
okey what you can do is that in your query you can join them...

select firstname+lastname as fullname

now you can use that fullname in your query. This is how I have done in past.
Regards,
---Pinal
0
 
kkhippleCommented:
what you might want to do is make this concatenation (joining of strings) within the query

CFSELECT: http://livedocs.macromedia.com/coldfusion/5.0/CFML_Reference/Tags91.htm


<CFQUERY name = "getStaff" ... >
SELECT firstName, lastName, firstName || lastName as fullName, StaffID
FROM users
</CFQUERY>

<cfselect query="getStaff" value="StaffID" display="fullName"  name="preparedby"></cfselect>
0
 
Renante EnteraSenior PHP DeveloperCommented:
Hi theamzngq!

I agree with what pinaldave and kkhipple posted.  Both of them are correct but you should have to take note regarding concatenation.  Depending on your database, some uses "||" or "+".

But, why not using <select> tag ???  I think, it's simple and clean :-?

:: USING <select> ::
  <select name="preparedby">
    <cfoutput query="getStaff">
      <option value="#StaffID#">#FirstName# #LastName#</option>
    </cfoutput>
  </select>

Hope this helps you.  Just try it.


Goodluck!
eNTRANCE2002 :-)
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
David WilliamsonIT DirectorAuthor Commented:
You're right, entrance, I could do that.  I usually do, actually, but I have a new found desire to take advantage of the built in functionality that CF has to offer.  I spend a lot of time working on forms, and I'm trying to use as much automated stuff as possible.  In the end, using a regular select is probably easier.
0
 
pinaldaveCommented:
Hi theamzngq,
do you still need help. or it is all good now.

Regards,
---Pinal
0
 
David WilliamsonIT DirectorAuthor Commented:
Sorry, I haven't tried it out yet.  But I will today, and let you know...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now