EasyCFM.COM ColdFusion Forums / Tutorial Requests! / Query display value

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Query display value

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

borricua1
04-27-2004 @ 6:29 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 45
Joined: Apr 2004

is there any way I can display more than one variable in the select box?

<cfselect name="Branches"
    query="get_branches"
    value="branch_number"
    display="branch_number" <!--- I.e. I want not only number but name here also to display in the select option--->
    required="Yes"
    multiple="no"
    size="1">
  </cfselect>


ianwinter
05-05-2004 @ 4:30 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 56
Joined: Jul 2003

It can't be done with the cfselect tag, but there are a couple of ways you could do it.

You could alter the query to create a psuedo column that had both values in (this is Oracle syntax):

<cfquery datasource="dsn" name="q_emp">
SELECT empid, empname||' ('||empid||')' as employee FROM employees
</cfquery>

<cfform>
     <cfselect name="Employees"
          query="q_emp"
          value="empid"
          display="employee"
          required="Yes"
          multiple="no"
          size="1">
     </cfselect>
</cfform>

Or you could do it the HTML way:

<cfquery datasource="dsn" name="q_emp">
SELECT empid, empname FROM employees
</cfquery>

<form>
     <select>
     <cfoutput query="q_emp">
          <option value="#empid#">#empname# (#empid#)</option>
     </cfoutput>
     </select>
</form>

With this though you'd have to write your own either CF or JS validation.

HTH,
Ian

Bored? Check out www.office-humour.co.uk

Advanced Certified ColdFusion MX Developer
Team Macromedia Volunteer for ColdFusion

borricua1
05-05-2004 @ 3:49 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 45
Joined: Apr 2004

Thanks man I used your second suggestion and it worked out fine..

ianwinter
05-07-2004 @ 5:34 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 56
Joined: Jul 2003

No problem. Smile

Bored? Check out www.office-humour.co.uk

Advanced Certified ColdFusion MX Developer
Team Macromedia Volunteer for ColdFusion

Sponsored By...
iOpenSoft, LLC is a Houston, Texas Advanced Technology Studio Specializing in Web Design, Web Development, iPhone App Development and Android App Development.