Title: Drop Down Menu
Last modified: March 4, 2019

---

# Drop Down Menu

 *  Resolved [supernova42](https://wordpress.org/support/users/supernova42/)
 * (@supernova42)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/drop-down-menu-145/)
 * I’m using a DropDown Menu such as
 * CHANNEL ISLANDS
    …lots of town here ENGLAND …lots of town here SCOTLAND …lots
   of town here WALES …lots of town here IRELAND …lots of town here
 * The list is formatted like this
 * CHANNEL ISLANDS ::optgroup,Bouley Bay::bouley-bay,Braye::braye,Maseline
 * and all works correctly.
 * However the list is huge with over 700 entries to select from.
 * I was thinking of having a DropDown Menu with just the countries such as
    CHANNEL
   ISLANDS ENGLAND SCOTLAND WALES ETC
 * The User would first select the Country and then choose the corresponding towns
   from another DropDown Menu.
 * Obviously the towns for each of the countries would be kept in separate arrays,
   and by selecting the country would point to the appropriate array.
 * Is there an easy way to do this please.
 * Thanks

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Thread Starter [supernova42](https://wordpress.org/support/users/supernova42/)
 * (@supernova42)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11274936)
 * This is how far I’ve got so far Roland
    What I need to know is how do I fill 
   the array for the variable $tidal_location which is in a dropdown menu and how
   would I format it?
 * >  [insert_php]
   >  $current_user = wp_get_current_user(); $wp_username = $current_user-
   > >user_login; $user_id = Participants_Db::get_record_id_by_term(‘username’,$
   > wp_username); $data = Participants_Db::get_participant($user_id); $tidal_area
   > = $data[‘tidal_area’]; $tidal_location = $data[‘tidal_location’];
   > switch ($tidal_area) {
   >  case “UK Channel Islands”: // load array for Channel
   > Islands break; case “UK England”: // load array for England break; case “UK
   > Ireland”: // load array for Ireland break; default: echo ‘No Tidal Area Specified…’;}[/
   > insert_php]
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11277989)
 * Something like this has to be done in Javascript, you can’t do it in php.
 * Check out this article, I think I sent you there before, it explains one way 
   to do this: [Dropdown Selectors: limit selections based on another selector ](https://xnau.com/dropdown-selectors-limit-selections-based-on-another-selector/)
 *  Thread Starter [supernova42](https://wordpress.org/support/users/supernova42/)
 * (@supernova42)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11279151)
 * Okay Roland I followed your instructions
    I wanted to use the ‘pdb-record-default’
   template so I copied it and named it ‘pdb-record-arcona’. I then copied the javascript
   code into the template file. The script went straight after the top closing ?
   > tag. In this new template file I changed the name of the parent to ‘tidal_area’
   and the child to ‘tidal_location’. These are the names of my fields in PDB. I
   then uploaded my new template file to my templates folder.
 * In Manage DataBase Files I have the two fields described above. I copied your
   sample State text into my tidal_area dropdown list. I then copied the sample 
   city text into my tidal_location dropdown list.
 * All was going well
 * I inserted the following shortcode into one of my pages. The shortcode contains
   tidal_area and tidal_location.
 * [pdb_record template=”arcona” fields=”username,boat_name,boat_model,sail_number,
   boat_owner,build_year,boat_length,berthed_at,tidal_area,tidal_location,tidal_days,
   state,city,latitude,longitude,registration,registration_no,radio_callsign,mmsi,
   website_address,brief_description,single_photo” record_id=1008]
 * The parent dropdown field (tidal_area) contained the states as expected. I selected
   one of the states and when I went to the child dropdown field (tidal_location)
   it contained all the states and all the cities. It hadn’t restricted the list
   and basically its not working.
 * Is there anything obvious I’ve missed out. If not is it possible that the template
   needs updating.
 * Many thanks
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11279816)
 * I’m sorry…nothing I see there indicates what the problem is, but most likely 
   you’ll need to debug your javascript. Your browser developer tools are very helpful
   for that.
 *  Thread Starter [supernova42](https://wordpress.org/support/users/supernova42/)
 * (@supernova42)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11281064)
 * I’ve found the problem Roland – Browsers!!!
 * It works with Firefox, Chrome on my iMac.
    It doesn’t work on Safari on my iMac.
 * I’ve tried differents templates and the result is the same.
 * I’ve tried Firefox, Chrome, Safari on my iPad and it doesn’t work with any of
   those.
 * Any suggestions
 * Thanks
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11287519)
 * Make sure your javascript is compatible with all browsers. You can use the Browser
   Developer tools console to look for issues with the javascript when testing the
   page.
 *  Thread Starter [supernova42](https://wordpress.org/support/users/supernova42/)
 * (@supernova42)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11287530)
 * The javascript I’m using Roland is the one from the link you provided.
 * i.e. Dropdown Selectors: limit selections based on another selector.
 * Do you know of any problems with at script?
 * Thanks
 *  Thread Starter [supernova42](https://wordpress.org/support/users/supernova42/)
 * (@supernova42)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11358801)
 * I’ve abandoned that. It’s too unreliable…

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Drop Down Menu’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [supernova42](https://wordpress.org/support/users/supernova42/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/drop-down-menu-145/#post-11358801)
 * Status: resolved