Click to See Complete Forum and Search --> : multi drop down boxes from db


tasneem
06-10-2005, 01:36 PM
Hi
I want to have 3 dynamic drop down boxes from access db, with the first one static, and the next 2 deriving results based from db. Can someone get me some idea of code for this?
The exact sequence is this:

Box 1 has - (static)
categories
manufacturers
keywords

Box 2 should -
display categories, or manufacturers from Box 1 choice, but go to list page for keywords choice. So for keyword choice, just a text box to appear to type in the keyword.

Box 3 should -
display subcategories for Box 2 choice (for categories only), but go to list page for manufacturers choice. So box should not appear for manufacturers choice.


Also, another thing - the keyword in the db table can be multiple, but I need to get all the results even if one keyword is entered in the text box.

Please post some ideas on how best to progress with this, and is this even possible?

Thanks

buntine
06-12-2005, 09:25 PM
Everything is possible. You just need to figure out the best way to achieve your goal.

As ASP is a server-side technology, it cannot dynamically alter the contents of a client-side control without first reprocessing on the server (refreshing the page). JavaScript, however, can.

You can generate the contents of a combo box by doing something similar to this:

Response.Write ("<select name=""categories"">")
yourRecordSet.MoveFirst
For i = 0 To yourRecordSet.RecordCount
Response.Write("<option value=""" & yourRecordSet("categoryID") & """>" & _
yourRecordSet("categoryName") & "</option>")
yourRecordSet.MoveNext
Next
Response.Write ("</select>")

This example assumes you are getting your data from a database using a RecordSet object.

The exact method for your application will differ, but the concept is the same. If you want client-side processing, you may need to import all the data into a javaScript method and use that to dynamically generate the contents for box2 and box3 based on user selections.

Regards.

tasneem
06-12-2005, 10:01 PM
Hi
so for the first box, where the data is static (list is typed), I should use javascript to pass the variable to the next box? Will this refresh the page?
my dynamic boxes will use the recordsets to loop thru. I have the code to pass info from one dynamic box to another, but I am unsure of what to do with the first one - where the list is not db based.
Also, how to make the boxes appear only on some choice, not be there by default.
Also the keyword choice - where the db field may have multiple keywords or plurals/singulars and user types in only one keyword - how to take that?
The site is quite busy, so also have to take that into account.
thnx

buntine
06-12-2005, 11:22 PM
There are quite alot of requirments there. Each one cunfuses the requirement so I cannot see myself providing a solution for each without seeing the system and working on it locally.

Initially, you can use ASP to generate the contents for each combo box (except for the first one which is hardcoded). You may want a JavaScript function that sorts the data in each combo based on the users selection's. Note, this will limit your audience to those who accept JavaScript (about 91%). And the JavaScript function will run from the clients browser and will not cause the page to refresh.

The first list box is hadcoded and therefore can just be flat HTML. Preventing the boxes from displaying can be done with a basic If Statement. ow you want to do it is up to you. You could use a checkbox, for example.

Regards.

tasneem
06-14-2005, 01:38 PM
Hi
I will work on this, and post some sort of progress and code here for follow up soon.
Thanks