Support

Account

Home Forums General Issues Load other value of field A when changing value of field B

Unread

Load other value of field A when changing value of field B

  • Hi at all,

    I’ve got a acf_form with a lot of different fields. One field (A) is a select, and another field (B) is a textarea. Now I try to change the value of field B when I change the value of field A.

    I tried it like this, but this didn’t work:

    add_action('wp_head', 'acf_custom_post_template_js');
    function acf_custom_post_template_js() {
      echo "<script>
            jQuery(function($){
                $('#customer-select select').on('change', function(){
                    alert('test'); 
                    $(document).trigger('acf/load_field/name=dir');
                });
            });
        </script>\n";
    }
    
    function acf_load_kunde_dir( $field ) {
        
       //var_dump($field);
       echo '<script>console.log("testing")</script>';
        return $field;
        
    }
    
    add_filter('acf/load_field/name=dir', 'acf_load_kunde_dir');

    Do I have to work with an ajax function or is there another possible solution?

Viewing 1 post (of 1 total)

The topic ‘Load other value of field A when changing value of field B’ is closed to new replies.