cfselect and bind

I got to use more binding this week. Oh what a joy. Just don’t have any errors in your SQL, your CFC, or your cfselect

formpage.cfm
cfselect name="partnum" bind="cfc:part_functions.getPartnum()" value="partnum" bindonload="yes"

part_functions.cfc – Note brackets removed due to coding issues.
cffunction name="getPartnum" access="remote" hint="get a list of the partnumbers"
 
cfset var qPartnum = ''
 
cfquery datasource="#DSN#" name="qPartnum"
select ' All' as Partnum
UNION ALL
select distinct Partnum
from parts_table
order by Partnum
/cfquery>
 
cfreturn qPartnum
/cffunction>

Notice the space in the SQL ” All” as Partnum. That allows All to be the first option after the sort, I can then perform logic tests against it when passing the form values. You can also just use a blank value or zero.

Cup size   
Select size then click on coffee cup.
This entry was posted in Code, Coldfusion. Bookmark the permalink.