Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop down box

Status
Not open for further replies.
May 29, 2001
10
GB
Hi Guys,

I have a drop down box which lists suppliers of courses. This allows the user to select a supplier and see some feedback on that course.

How do I insert in that drop down box an 'All' option which allows the user to view all courses from the database?

Regards

Dave
 
Hi Dave,

Something like this should work for you.

<select name=&quot;courseID&quot;>
<option value=&quot;-1&quot;>All
<option>Course 1
<option>Course 2
<option>Course 3
....
</select>

On the action page...
<cfquery name=&quot;getCourses&quot; datasource=&quot;myDS&quot;>
select * from courses
<cfif courseID neq -1>
where courseName = '#courseID#'
</cfif>
</cfquery>

The trick is finding a value for the &quot;all&quot; case that you know will never conflict with a value from one of the courses.

Hope this helps,
GJ
 
Thanks GunJack,

The 'All' option works just as I want it, and by that I mean it picks up all courses from all suppliers, however in the intial drop down box where the suppliers are listed, the 'All' option is listed after every supplier e.g.
----------------------
Course Suppliers -
suppA
All
suppB
All
suppC
All
----------------------
I can't seem to just display one option of 'All'. Any idea's?

Regards

Dave
 
Try

<select name=&quot;courseID&quot;>
<option value=&quot;-1&quot;>All
<cfoutput query=&quot;getcourses&quot;>
<option>#Course1#
<option>#Course2#
<option>#Course3#
</cfquery>
</select>
John Hoarty
jhoarty@quickestore.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top