[thelist] <select> and defaulting to "All"

David Crowther david at SITD.COM
Fri Aug 4 05:57:58 CDT 2000


Thanks Jed... I have got it sorted now. I am using an IF statement.

<select name="County" size="1">
<option value="" selected>All</option>

SELECT
tblCustomerDetails.CustomerID,tblCategories.CategoryID,CompanyName,County
FROM ((tblCustomer inner join tblCustomerDetails on tblCustomer.CustomerID =
tblCustomerDetails.CustomerID) inner join tblCategories on
tblCustomer.CategoryID = tblCategories.CategoryID) WHERE
<cfif attributes.County GT "">County = '#attributes.County#' AND</cfif>
tblCustomer.CategoryID = #attributes.CategoryID# ORDER BY CompanyName

Cheers
David



-----Original Message-----
From: Jed Farr [mailto:jedf at antech.co.uk]
Sent: 04 August 2000 11:17 AM
To: 'thelist at lists.evolt.org'
Cc: David Crowther
Subject: RE: [thelist] <select> and defaulting to "All"


You might want to have a look at the LIKE SQL keyword and use % instead of
*. Your select might now look like:

<select name="County"
        size="1">
		<option value="%" selected>All</option>
		<option value="Aberdeenshire">Aberdeenshire</option>
		<option value="Anglesey">Anglesey</option>
		<option value="Angus">Angus</option>
		<option value="Antrim">Antrim</option>... etc

And your query:

<cfquery name="getSearchResults" datasource="#application.database#"
dbtype="ODBC">
		SELECT
tblCustomerDetails.CustomerID,tblCategories.CategoryID,CompanyName,County
		FROM ((tblCustomer inner join tblCustomerDetails on
tblCustomer.CustomerID = tblCustomerDetails.CustomerID)
		inner join tblCategories on tblCustomer.CategoryID =
tblCategories.CategoryID)
		WHERE County LIKE '#form.County#'
		AND tblCustomer.CategoryID = #form.CategoryID#
		ORDER BY CompanyName
		</cfquery>

I think that this would work with my db of choice (ms sql server), but
you'll have to check the syntax for your db.

Regards,

Jed.


________________________________________________________________ 
Jed Farr 
jedf at antech.co.uk <mailto:jedf at antech.co.uk> 
http://www.antech.co.uk

AnTech Ltd, Unit 7, Newbery Centre, Airport Business Park, Exeter UK. EX5
2UL 
Tel +1 800 789 7515 Direct +44 (0)1392 440338   Fax: +1 281 754 4333 


> -----Original Message-----
> From: David Crowther [mailto:david at SITD.COM]
> Sent: Friday, August 04, 2000 10:46 AM
> To: 'thelist at lists.evolt.org'
> Subject: [thelist] <select> and defaulting to "All"
> 
> 
> I am providing a compound search option in a site that I am coding in
> ColdFusion. The two search choices are by County and Category.
> I want to set the default option to "All" (all the counties) 
> in the County
> field.
> 
> For example:
> 
> <select name="County"
>         size="1">
> 		<option value="*" selected>All</option>
> 		<option value="Aberdeenshire">Aberdeenshire</option>
> 		<option value="Anglesey">Anglesey</option>
> 		<option value="Angus">Angus</option>
> 		<option value="Antrim">Antrim</option>... etc
> 
> 
> And my query code:
> 
> <cfquery name="getSearchResults" datasource="#application.database#"
> dbtype="ODBC">
> 		SELECT
> tblCustomerDetails.CustomerID,tblCategories.CategoryID,Company
> Name,County
> 		FROM ((tblCustomer inner join tblCustomerDetails on
> tblCustomer.CustomerID = tblCustomerDetails.CustomerID)
> 		inner join tblCategories on tblCustomer.CategoryID =
> tblCategories.CategoryID)
> 		WHERE County = '#form.County#'
> 		AND tblCustomer.CategoryID = #form.CategoryID#
> 		ORDER BY CompanyName
> 		</cfquery>
> 
> As you can see I have tried using a * as the first option in 
> my <select>
> tag, but unfortunately this does not work.
> 
> Does anyone have an idea how I can get this to work... many thanks in
> advance.
> 
> David
> 
> <tip type="Photoshop 5.5">
> Don't forget in Photoshop 5.5 to tick the "Only Web Colors" 
> box in the Color
> Picker when you want to make sure your web site is web safe.
> </tip>

---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt ! 




More information about the thelist mailing list