Search code examples
sqlsql-server-2008coldfusioncoldfusion-8

Adding Select All to dropdown


This is my query:

 <cfquery name="qry" datasource="#variables.staffDs#">
  SELECT
    firstname + ' ' + surname name, userid, mobileno, extension
  FROM
    currentstaff
  WHERE
    (mobileno IS NOT NULL OR
     Left(LTrim(extension), 2) = '07')
 </cfquery>

This is my ColdFusion dropdown box:

  <select name="to" id="to">
  <option value=""> -- Select -- </option>
  <option style="font-weight: bold" value="">Send to All</option>
  <cfoutput query="people">
    <option value="#qry.userid#">#qry.name#</option>
  </cfoutput>
  </select>

The names of all people are displayed in the dropdown box list.

What I'd like to do is add an option at the top of the dropdown box to 'Sent to All' to select all users and I'm not sure how to do this.

I'd like to incorporate any extra SQL I might need into my current query, if this is necessary.


Solution

  • you just need to change like this if possible , just add

    Select 'Select All'
     union
    

    to your query , final code like

     Select 'Select All','','',''
     union
     SELECT
        firstname + ' ' + surname name, userid, mobileno, extension
      FROM
        currentstaff
      WHERE
        (mobileno IS NOT NULL OR
         Left(LTrim(extension), 2) = '07')