Support

Account

Forum Replies Created

  • Been playing around and so far this is my code that works, it gets the value of the checkbox but only on the selected/saved one. The code below gives me “southern 360” where 360 is the value of the saved/selected checkbox and southern is the correct region if based on the 360 ID. This is the same on all checkbox divs though and what I need is for each checkbox div to show the ID value of its respective checkbox.

    How can I change it so that it will add the value of the checkbox per checkbox and not the selected one?

    function filter_region_taxonomy() { ?>
    <script type="text/javascript">
    (function($) {
    // Document Ready
    $(document).ready(function() {
    $('#acf-standard_region select').trigger('change');
    });
    $('#acf-standard_region .acf-taxonomy-field select').live('change', function() {
    var value = $(this).val();
    $( "#acf-standard_company:checkbox" ).addClass("compclass");
    
    if( value == "7" ) {
    $( "#acf-standard_company ul.acf-checkbox-list li ul.children li" ).removeClass( "southern no-class" ).addClass(("<?php $terms = get_the_terms( get_the_ID(), 'company'); if( !empty($terms) ) { $term = array_pop($terms); $term_id = $term->term_id; $regionVal = get_field('jobsite_region', 'company_' . $term_id ); echo $regionVal . ' ' . $term_id; } ?>"); 
    $('#acf-standard_company').show();
    $('ul.acf-checkbox-list li').show();
    }
    else if( value == "9" ) {
    
    $( "#acf-standard_company ul.acf-checkbox-list li ul.children li" ).removeClass( "northern no-class" ).addClass(("<?php $terms = get_the_terms( get_the_ID(), 'company'); if( !empty($terms) ) { $term = array_pop($terms); $term_id = $term->term_id; $regionVal = get_field('jobsite_region', 'company_' . $term_id ); echo $regionVal . ' ' . $term_id; } ?>");
    $('#acf-standard_company').show();
    $('ul.acf-checkbox-list li').show();
    }
    else {
    $( "#acf-standard_company ul.acf-checkbox-list li ul.children li" ).removeClass( "southern northern" ).addClass( "no-class" );
    $('#acf-standard_company').hide();
    $('ul.acf-checkbox-list li').hide();
    }
    
    });
    
    })(jQuery);
    </script>
    
    <?php }
    
    add_action('acf/input/admin_head', 'filter_region_taxonomy');
  • @jonathan Thanks, I’ve added it as a code element. Any help would be greatly appreciated.

Viewing 2 posts - 1 through 2 (of 2 total)