Skip to main content
Known Participant
July 8, 2011
Question

using javascript to populate one menu based on the choice in another menu

  • July 8, 2011
  • 1 reply
  • 634 views

I have several menus which are dynamically populated (with PHP and MYSQL). The information is category based. How do I dynamically populate the second menu based on the choice the user makes in the first menu (without having to submit and refresh the page-- i.e. I need to use javascript instead of the server-side PHP).

Example:

Main Categories: 1) Numbers     2) Letters

Sub Categories:        1                      a

                               2                      b 

                               3                      c

                              etc.                  etc.

the first menu contains the two main categories. I want the second list to be populated with only the sub categories of the main category the user chooses in the first menu (i.e. 1,2,3 etc. if he chose the main category 'Numbers' and a,b,c, etc. if he chose the main category 'Letters')

Is there an easy way to do this in Dreamweaver?

Thanks,

YWSW

This topic has been closed for replies.

1 reply

Participating Frequently
July 8, 2011

How many items do you have in each dropdown? If it's a small number, you can download all of the options for the second dropdown and use client side javascript to filter based on the choice of the first dropdown. If the number is large, you'll need to use AJAX to dynamically pull the related items from the database.

Search the web for "dependent dropdown" or "cascading dropdown" for some technical details.

YWSWAuthor
Known Participant
July 8, 2011

breqent, thanks for the response.

both the first and second menu are very large. I also have other large sub-category menus as well. I there any simple way to do this in dreamweaver?

Participating Frequently
July 8, 2011

>I there any simple way to do this in dreamweaver?

I don't know of any DW server behaviors that will do this, if that's what you mean. You're going to need to do some coding here.