Add blank record to bound cfselect

Posted on 2009-04-19
Last Modified: 2012-05-06
I'm trying to figure out a way to return the getSaleBuyers4cfselect query with a black record in case the user wants to leave it blank.
<cfselect name="sale_buyer_id" id="sale_buyer_id" size="1" bind="cfc:lots.addWindow.getSaleBuyers4cfselect()" bindonload="true" display="sale_buyer_Name" value="sale_buyer_id" />

<!--- Sale Buyers CFC to fill the cfselect query --->

<cffunction name="getSaleBuyers4cfselect" access="remote" returntype="query" output="false">

<cfset var qGetSaleBuyers="">

<cfquery name="qGetSaleBuyers" datasource="#request.dsn#">

SELECT sale_buyer_id, sale_buyer_name

FROM sale_buyer

ORDER BY sale_buyer_name


<cfreturn qGetSaleBuyers />


Open in new window

Question by:MFredin
    LVL 27

    Accepted Solution

    use a UNION query in your cfc:

    <cfquery name="qGetSaleBuyers" datasource="#request.dsn#">
    (SELECT 0 AS sale_buyer_id, '' AS sale_buyer_name, 0 AS sortcolumn
    FROM sale_buyer)
    (SELECT sale_buyer_id, sale_buyer_name, 1 AS sortcolumn
    FROM sale_buyer)
    ORDER BY sortcolumn, sale_buyer_name

    the sortcolumn column has been added to allow proper sorting of the union'd resultset


    Author Comment

    Thanks again Azadi! Perfect!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
    Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 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

    21 Experts available now in Live!

    Get 1:1 Help Now