PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Filtering dropdown values

  1. Winston
    Member

    In a form I've included two dropdowns, populated by two custom taxonomies: States and Cities.

    I would like to filter the cities shown in the second dropdown to a selection of cities that are in a previously selected state.

    Is there a hook I can use to filter which fields get shown in a dropdown populated by a taxonomy?

    Many thanks!

    Posted 14 years ago on Sunday May 1, 2011 | Permalink
  2. There isn't currently a hook for this because it wouldn't be done with PHP, you'd have to do this using jQuery. You'd have to use jQuery to dynamically change the values based on the previous selection. Doing it with PHP would require a page refresh. So you'd have to write custom jQuery to accomplish what you want to do.

    Posted 14 years ago on Monday May 2, 2011 | Permalink
  3. Winston
    Member

    Thanks Carl.

    I was considering actually creating a couple of dropdowns with the city lists, one for each state (I "only" need 7) and then displaying just one based on conditional logic.

    Is filtering a list of categories in such a way to have only certain fields in the dropdown instead of all the category elements possible?

    Posted 14 years ago on Tuesday May 3, 2011 | Permalink
  4. Hi,
    as i've the same question as Winston, and i'm novice in jQuery, can you please make a little example on how i can build the jQuery script?
    Thanks in advance

    Posted 13 years ago on Friday April 20, 2012 | Permalink