On the Fly PICK Filtering

0

Hello all,

So, I have a pod called CONTINENTS that have the entries North America, South America, and Asia I have another pod called COUNTRIES that have the entries Canada, USA, Chile, Brazil, Japan, and China I have another pod called CITIES that have the entries New York, Tokyo, Rio, etc

When adding entries to the CITIES pod, I have a PICK column that selects for COUNTRIES and another PICK column for CONTINENTS. Is there a way that I can filter the choices available in these PICK columns so that when entering the city Detroit, I can select NORTH AMERICA and only be given the option of Canada and USA? Basically, filter the choices on the fly?

I'd also love for this to work with a Multi-Pick Column, if possible. In reality, I'd like to implement this system for a staff directory that allows you to choose which department(s) and division(s) a member is in.

Thanks! Frank

asked Nov 8 '10 at 4:14

Frank

1

yep, I need this as well. to have pick lists created by the choice made in another – leeburstroghm Jul 7 '11 at 3:36
add comment
enter at least 15 characters

5 Answers

0

any ideas?

answered Nov 11 '10 at 8:08

Frank

1

add comment
enter at least 15 characters
0

Looking for this type of functionality too

answered Feb 12 '11 at 10:14

markol

1

add comment
enter at least 15 characters
0

Out of the box there currently is not an option for this, but it is possible to develop a custom helper to do this for you. You could also develop your own admin screen/forms for this using the Pods API to give you some more flexibility.

answered Feb 14 '11 at 1:59

hsatterwhite

211

add comment
enter at least 15 characters
0

Was this custom helper ever built? Really need this functionality as well. Have about 10 parent categories, then each have 10-20 sub-categories. Need sub-category dropdown to be refreshed on the choice of parent category on a search page. Thanks

answered Jul 20 '11 at 2:04

inspiration

7

edited Jul 20 '11 at 2:24

add comment
enter at least 15 characters
0

I wanted to do something similar.

I have regions with associated cites and I wanted to narrow the list of cities based on the selected region.

This is the approach I used.

I attached this as a display helper; it could be added to the city PICK or region PICK. Warped with javascript script tags.

jQuery(function() {
  jQuery("#pods_form0_region_name").change(function() {
    jQuery.getJSON("<?php bloginfo('siteurl'); ?>/ajax/?cities_region_id=" + jQuery("#pods_form0_region_name").val(), function(j){
      var options = '<option value="">-- Select one --</option>';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].city_id + '">' + j[i].city_name + '</option>';
      }
      jQuery("#pods_form0_city_name").empty();
      jQuery("#pods_form0_city_name").append(options);
    });
  });
});

the code for ajax?cities_region_id

function get_region_cites_json($cities_region_id) 
{
  $cities = new Pod('city');

  $params = array();
  $params['select'] = "t.id, t.name";
  $params['where'] = "region_name.id = '".pods_sanitize($cities_region_id)."'";
  $cities->findRecords($params);
  $total_cities = $cities->getTotalRows();

  $cities_array = array();
  if ($total_cities > 0)
  {

    while ($cities->fetchRecord())
    {
      $cities_array[] = array('city_id' => $cities->get_field('id'), 'city_name' => $cities->get_field('name'));
    }

    echo json_encode($cities_array);
  }
}

I might detail this more on my blog, when I get one set up.

answered Jul 20 '11 at 5:55

richardbakeretc

18

edited Jul 27 '11 at 12:55

add comment
enter at least 15 characters