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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parent-child drop-down boxes

Status
Not open for further replies.

david7777777777

Programmer
Sep 26, 2001
417
US
I have ASP pages that serve as the user interface to a SQL 2000 database. I'd like to have 2 drop-down boxes on one of my ASP pages. I want the selection in one box to determine the selections that are available in the other box. For instance:

Box #1 lists car manufacturers:
1. Ford
2. Chevy
3. Mazda

Box #2 lists the models produced by each manufacturer:
1. Mustang
2. Taurus
3. Camaro
4. Impala
5. Miata
6. 626

When a selection is made in box #1 the appropriate selections automatically populate box #2, regardless of how many times the user makes a differnet selection in box #1. I'm guessing I'll need to grab the onchange event for box #1 but I've never done this before and I'm hoping someone can point me in the right direction. Thanks.
 
Yes, the onchange will work just fine. It can cause a server round-trip - which can be a bit un-settling for some users. You could supply the complete list of models to the client, and use client-side javascript to re-populate the second combo-box, but I cannot provide code for this - and the initial page load may be slower if the model list is very long.

Remember that recordsets used for a combo DTC need only be opened ONCE - the combo caches the list as a hidden form field. So add recordsets that do NOT auto-open on page load, and just open then close them manually...

sub cmbManufacturers_onchange()
'clear the current combo data
cmbMyCombo.clear
rsList_comboData.setParameter 0, txtManufacturer.value
rsList.open
'combo auto-populates here!
rsList.close
end sub (Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top