The filtering capabilities of dynamic dropdowns give your website visitors a way to quickly narrow their search by drilling down from a parent category to a child subcategory. This Getting Started Guide will show you how to create two menu lists that add specific selections to a target list, for example, finding an auto part for a specific car. You can also use dynamic dropdown behaviors to provide Add to List, Remove, Select All, and Move Up or Down options to a form, for example, specifying a group of email addresses in an existing list.
- Dreamweaver CS4 or higher.
- Data Bridge (alternately, Dynamic Dropdowns) installed and activated in Dreamweaver.
- Site defined in Dreamweaver with a saved PHP page - Watch video tutorial: Setting up a site in Dreamweaver.
- PHP connection in Dreamweaver to your database. For assistance, view this tutorial: Create a PHP database connection.
Before you begin using Dynamic Dropdowns, you must ensure that your database is configured properly to display the data you need.
- Once you have decided on how you will implement Dynamic Dropdowns, you will need the database tables to support this. Depending on your needs, your database may need more than two tables.
- Parent table: One table will be required as the first menu list.
- Child table: Another table will be required as the Child table.
Example: If this were an automotive website, the Parent table would contain all the manufacturers in the content (text) column. The Child table would contain the various models with the manufacturer ID from the Parent table.
- The Parent table only requires two columns, one for the ID, another for content. More columns are permitted, but not required.
- The Child table must include an ID column, a Secondary key to the Parent table’s ID, and one for the content.
More details regarding configuring your database can be found in the Context-sensitive help documentation built into the product.
With your database configured, your next step is to add the menu/lists to a page on your website. For this example, we will create a menu list for the parent table, another for the child table, and a final list to which we will add our selections.
- Parent list
- Place your cursor where you wish to insert the Parent list.
- In Dreamweaver, go to Insert > Form > Select (List/Menu).
- In the ID field enter Parent.
- In the Label field enter Parent. (The names for IDs and Labels are tutorial examples.)
- Click OK.
- Click Yes when asked to add form tag.
- Select your new list.
- In the Properties Inspector, choose the List radio button.
- Set the Height to 10.
- Child list
- Go to Insert > Form > Select (List/Menu) again.
- Enter Child in the ID field.
- Enter Child in the Label field.
- Click OK.
- Select the Child list that was just created.
- In the Properties Inspector, choose the List radio button.
- In the Height field, enter 10.
- Choose the Allow multiple checkbox to allow you to select multiple items from this list.
- Target list
The target list is not necessary for all applications of Dynamic Dropdowns.
- Go to Insert > Form > Select (List/Menu) again.
- Enter Target in the ID field.
- Enter Target in the Label field.
- Click OK.
Dynamic Dropdowns can apply various behaviors to form buttons to add some useful functionality to your lists. The following steps in this section show how to create each button using Dreamweaver’s built-in functionality. (The subsequent sections will show how to use Dynamic Dropdowns to make these buttons active.)
- Create the Add to List button which adds selections from a list/menu to a target list
- Choose the Button option from the Forms toolbar.
- In the ID field, enter Add.
- Leave the Label field blank, and click OK.
- Select the button that was just created.
- In the Properties Inspector, replace Submit in the Value field with Add to List.
- Choose None from the Action options.
- Repeat the steps to create the Remove button which removes the selected item(s) in a list.
- Choose the Button option from the Forms toolbar.
- In the ID field, enter Remove.
- Leave the Label field blank, and click OK.
- Select the button that was just created.
- In the Properties Inspector, replace Submit in the Value field with Remove.
- Choose None from the Action options.
- Repeat the steps to create the Select All button which selects all the items that are in the list.
- Choose the Button option from the Forms toolbar.
- In the ID field, enter Select All.
- Leave the Label field blank, and click OK.
- Select the button that was just created.
- In the Properties Inspector, replace Submit in the Value field with Select.
- Choose None from the Action options.
- Repeat the steps to create the Move Up button which moves the selection above other items in the list.
- Choose the Button option from the Forms toolbar.
- In the ID field, enter Move Up.
- Leave the Label field blank, and click OK.
- Select the button that was just created.
- In the Properties Inspector, replace Submit in the Value field with Move Up.
- Choose None from the Action options.
- Repeat the steps to create the Move Down button which moves the selection below other items in the list.
- Choose the Button option from the Forms toolbar.
- In the ID field, enter Move Down.
- Leave the Label field blank, and click OK.
- Select the button that was just created.
- In the Properties Inspector, replace Submit in the Value field with Move Down.
- Choose None from the Action options.
- View the completed buttons on your page.
Your parent and child lists will both require recordsets before you apply the Dynamic Dropdowns behaviors.
- From the Server Behaviors panel, choose the Add icon.
- Choose Recordset.
- In the Name field, enter Parent.
- Choose your database connection from the Connection list.
- Choose the parent table (in the eCommerce database, this is productcategories) from the Table menu list.
- Click OK.
- Choose the Add icon from the Server Behaviors panel, again.
- In the Name field, enter Child.
- Choose your database connection.
- Select the child table (in the eCommerce database, this is products) from the Table menu list.
- Click OK.
Next, you will turn the Parent list, created earlier, into a dynamic list. As a dynamic list, the Parent list will be populated with the correct data from the database.
- Select the parent list on your page.
- In the Properties Inspector, choose the Dynamic option.
- In the Options from recordset menu, choose the Parent table.
- From the Values menu, choose the CategoryID column.
- From the Labels menu, choose the column that contains the CategoryName.
- Click OK.
Now that your page contains all the necessary elements for your Dynamic Dropdowns application, you will add the necessary behaviors to these elements.
- Create the dynamic array
- From the Server Behaviors panel, choose the Add icon
- Select WebAssist > Dynamic Dropdowns > Create Dynamic Array.
- From the Recordset menu, choose the Child table.
- From the Parent ID field menu, choose the ParentID column.
- From the Child ID field menu, choose the ChildID column.
- From the Child Value field menu, choose the column that contains the text or data for the child table.
- Click OK.
The following steps utilize the Dreamweaver Behaviors panel, which differs from the Server Behaviors panel.
- Populate list from array
- From the Window menu, choose Behaviors to open the Behaviors panel.
- Select the Parent list.
- Choose Add from the Behaviors panel.
- Choose WebAssist > WA Dynamic Dropdowns > Populate List from Array.
- From the Array source menu, choose the Child table.
- From the Source list, choose the parent list.
- From the Target list, choose the child list.
- Click OK.
- Press Ctrl (Cmd) + S to save your page.
- Add to List button
- Select the Add to List button on your page.
- From the Behaviors panel, choose Add.
- Select WebAssist > WA Dynamic Dropdowns > Add Value From Source List To Target List.
- From the source list, choose the Child list.
- From the Target menu list, choose the Target list.
- Click OK.
- Remove button
- Select the Remove button on your page.
- From the Behaviors panel, choose Add.
- Select Select WebAssist > WA Dynamic Dropdowns > Remove Selected From List.
- From the Target menu list, choose the Target list.
- Click OK.
- Select All button
- Select the Select All button on your page.
- From the Behaviors panel, choose Add.
- Select Select WebAssist > WA Dynamic Dropdowns > Select All In List.
- From the Target menu list, choose the Target list.
- Click OK.
- Move Up button
- Select the Move Up button on your page.
- From the Behaviors panel, choose Add.
- Select Select WebAssist > WA Dynamic Dropdowns > Change Position of Selected.
- From the Target menu list, choose the Target list.
- From the Move menu, choose Up.
- Click OK.
- Move Down button
- Select the Move Down button on your page.
- From the Behaviors panel, choose Add.
- Select Select WebAssist > WA Dynamic Dropdowns > Change Position of Selected.
- From the Target menu list, choose the Target list.
- From the Move menu, choose Down.
- Click OK.
- Press Ctrl or Cmd + S to save your page.
- Press F12 to preview your dynamic dropdowns and see how they work.
There are a number of applications for a dynamic dropdown, including providing filtering capabilities for an automobile website. This would allow users to choose their vehicle manufacturer in the first menu, which would then populate the second menu list with options related to that maker. This could even include a third dropdown for specifying more specifics regarding the car.
Another common use for dynamic dropdowns is to allow you to easily provide add, remove, select all, options to an existing menu/list, for example, an email form which contains a list of all possible email addresses. Using dynamic dropdowns you can specify any or all email addresses to send to and have those selections added to the To: field of your contact form.
Paolo R: 10 Years, 11 Months, 1 Week, 3 Days, 17 Hours, 43 Minutes ago
Thanks for this tutorial - Really helpful
Kate Ford: 10 Years, 11 Months, 1 Week, 3 Days, 17 Hours, 2 Minutes ago
You are welcome! Happy to hear it is helpful.
mmnpinto361034: 10 Years, 7 Months, 4 Days, 19 Hours, 13 Minutes ago
Trying to apply a repeat selection (6) and child and target Dynamic Dropdowns does not work any more. I aplly a repeat selection on a table line with 3 Dynamic Dropdowns and don't know how to deal with this. Any help please!!
Anna Robinson: 10 Years, 7 Months, 4 Days, 17 Hours, 4 Minutes ago
Sorry - Dynamic Dropdowns is not supported in a repeat selection because the form element names become dynamic in a repeat selection and Dynamic Dropdowns functionality is dependent on referencing the elements by name.
mmnpinto361034: 10 Years, 7 Months, 4 Days, 14 Hours, 54 Minutes ago
Thanks for the support!
russell298997: 10 Years, 3 Months, 3 Weeks, 2 Days, 15 Hours, 15 Minutes ago
DW CC doesnt have a list/menu select option??
Team WebAssist: 10 Years, 3 Months, 3 Weeks, 2 Days, 13 Hours, 53 Minutes ago
russell298997 - Yes, it's under Insert > Form > Select.
Maybe I'm not understanding the question...?
Rood's Media: 10 Years, 1 Month, 4 Weeks, 1 Day, 15 Hours, 29 Minutes ago
You lost me at making the actual database. MySQL makes no sense to me. It would be nice to have a tutorial on making the DB before hand.
Rood's Media: 10 Years, 1 Month, 4 Weeks, 1 Day, 15 Hours, 21 Minutes ago
Is there sample DB available for use with this tutorial? I am a visual person. I would like to see what I am supposed to be working with or trying to create. Thanks.
Team WebAssist: 9 Years, 8 Months, 2 Weeks, 6 Days, 14 Hours, 59 Minutes ago
Rood's Media, Thank you for the suggestion. In the meantime, if you aren't familiar with databases at all, go to Watch & Learn > Tutorials and search on mysql database. We have a free database, as well as a tutorial on getting started with databases. Using one of those should get you started in the direction of looking at the database tables and being able to start with the first section of this tutorial.