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>