I have posted this in the AJAX forum, but no responses so I thought maybe I might have asked or went about this from the wrong angle.

I have a search page written in CF. It has several form fields that a user can enter any combination of search criteria in and the results are returned in a dynamic table display. For example, if a user enters GE in the brand name field, over 500 records would be returned. I wanted to create some dropdown lists that would be populated by the initial search query that the user could then narrow down the search results. Again, for example, GE returned 500 results, then say for instance I had two dropdown lists were populated by the GE records. One could be Wattage dropdown list, the other could be Base Type, but all based on the specific brand of GE. This I think would be similiar to the drop down lists that you see on Ebay. When you search for a product like golf clubs, then you can narrow that down by other criteria such as brand, type of club, price, and so on.

I hope I explained this correctly. Anyway, thanks for any help.

hmm cant edit misspellings in titles..lol

Thanks for the info n_kip. I think I read this awhile back, but not sure that its what I'm needing. I will have to read through it again. What I want is for the user to type a search word in, which I already have, then be able to narrow those results down WITHOUT having to load another page. I know AJAX can be used for this, but again I dont know enough about AJAX to even begin to start coding it..lol Thanks again!

I think I know what you're asking and to relay the answer to you is the trick. :)

<!-- lets say you have a table for car types with the columns, car_id, body_type, make, model -->


<!-- Select your body_types, you'll need these first -->
<cfquery datasource="#datasource#" name="qCars">
	select body_type from cars
</cfquery>


<!-- Then your form to output your car body_types. -->

<form action="thispage.cfm" method="post">
	<select name="body_type">
		<cfoutput query="qcars" group="body_type">
			<option>#body_type#</option>
		</cfoutput>
	</select>
<BR>
<input type="submit" Value="Submit">
</form>
<BR><BR>


<!--- NOW ALL THE CARS WITH THAT PARTICULAR BODY_TYPE --->
<cfif isdefined('form.body_type')>
	<cfquery datasource="#datasource#" name="qgetcars">
		select *
		from cars 
		where body_type='#form.body_type#'
		order by make,model
	</cfquery>	

	<h3><cfoutput>#qgetcars.recordcount#</cfoutput> results for <cfoutput>#form.body_type#</cfoutput></h3>
	
<!-- OUTPUT your query into a table -->
<table align="center" width="100%">

<!-- This is for your top row -->
	<tr>
		<th>Number</th>
		<th>Make</th>
		<th>Model</th>
	</tr>
<!-- here are the rows returned for your filter of body_type -->
	<cfoutput query="qgetcars">
		<tr>
			<td>#currentrow#</td>
			<td>#Make#</td>
			<td>#Model#</td>
		</tr>
	</cfoutput>
</table>

</cfif>

Hope this helps. Its just an example, but this is how you would filter results from something already in your database. if you need more help, just write back on here, or contact me from my info in my profile.

Hey jsmall, thanks for the code. I haven't had a chance to try it out, so I will try too in the next few days and get back with you. Thanks again!\

One thing I will mention though, I wanted to use AJAX so the page wouldnt refresh everytime the user narrowed the results down. But again I will try this out.

actually i saw the ajax part after I wrote that, but its all good. Maybe a newbie will want what I posted. :) I dont think this will help you too much as far as what you're looking for right this in this thread.

ahh yes. I already have a good working search form and query. Thanks anyway!

No problem. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.