Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / January 2008



Tip: Looking for answers? Try searching our database.

cfselect - need to add option - binding issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cfwild - 30 Jan 2008 15:15 GMT
Hi,

I'm using the cfselect tag.  I'm binding the options to the tag using a cfc.  
I used to be able to insert additional <option> tags like this
<cfselect><option><option></cfselect>.  Using the binding cfc, the <option>
tags aren't showing up.  Thoughts?

Here's the code:

Thanks!

cfwild

cfselect tag>

<cfselect name="mediaid"
             bind="cfc:art.getMedia()"
             value="mediaid"  
             display="mediatype"
             bindonload="true">
            <option value=" ">Select All<option>
            </cfselect>

cfc:

<cfcomponent output="false">

   <cfset THIS.dsn="cfartgallery">

   <!--- Get array of media types --->
   <cffunction name="getMedia" access="remote" returnType="query">
      <!--- Define variables --->
      <cfset var data="">

      <!--- Get data --->
      <cfquery name="data" datasource="#THIS.dsn#">
      SELECT mediaid, mediatype
      FROM media
      ORDER BY mediatype
      </cfquery>

      <!--- And return it --->
      <cfreturn data>
   </cffunction>

</cfcomponent>
c_wigginton - 30 Jan 2008 21:20 GMT
Not a clean answer, but maybe this might work for you in a pinch.  Generate the
null first option in the query using a union statement or add it post query
using the code below.

<!--- put this after the data qry --->
<cfset sortAry = ArrayNew(1)>
      <cfset QueryAddColumn(data,"sort_order",sortAry)>
      <cfset QueryAddRow(data)>
       <cfset QuerySetCell(data,"mediatype","Select All")>
       <cfset QuerySetCell(data,"sort_order",1)>
        <cfquery name="qrySorted" dbtype="query">
        select * from data
        order by sort_order desc,mediatype asc
        </cfquery>
       <cfreturn qrySorted>
GArlington - 31 Jan 2008 09:48 GMT
> Hi,
>
[quoted text clipped - 17 lines]
>               bindonload="true">
>                          <option value=" ">Select All<option>

<snip>
The formating of your <option> may be causing the problem - that is
assuming that you copied and pasted your code and NOT retyped it
here...
Should be
<option value=" ">Select All</option>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.