WordPress widget query from a dropdown varialbe

i’m developing a custom widget, i would like to have a dropdown menu whithin which i can select one of the 3 availabe custom taxonomies of a custom post type.
This selection should provide the taxonomy within which a second operation will list – in another dropdown menu – all the terms of the selected taxonomy.

this is what i’ve done:

<div class="widget-option">
            <div class="widget-th">
                <label for="<?php echo esc_attr( $this->get_field_id( 'selezionato' ) ); ?>"><b><?php _e( 'Limit items', 'msd' ); ?></b></label> 
            </div>
            <div class="widget-td">
                <select id="<?php echo esc_attr( $this->get_field_id( 'selezionato' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'selezionato' ) ); ?>">
                    <option><?php _e( 'Seleziona la tipologia', 'msd' ); ?></option>
                    <option value="taxonomy_slug_1" <?php selected( $selezionato, "taxonomy_slug_1" ); ?>><?php _e( 'Taxonomy 1', 'msd' ); ?></option>
                    <option value="taxonomy_slug_2" <?php selected( $selezionato, "taxonomy_slug_2" ); ?>><?php _e( 'Taxonomy 2', 'msd' ); ?></option>
                    <option value="taxonomy_slug_3" <?php selected( $selezionato, "taxonomy_slug_3" ); ?>><?php _e( 'Taxonomy 3', 'msd' ); ?></option>
                </select>


                <select id="<?php echo esc_attr( $this->get_field_id( 'valori' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'valori' ) ); ?>">

                    <?php $cats = get_terms($instance['selezionato' ]);?>


                    <?php 

                    foreach($cats as $cat){ ?>   

                        <option value="<?php  echo $cat->slug; ?>" <?php selected( $instance['valori'], $cat->slug  ); ?>><?php _e( $cat->name,'msd' ); ?></option>

                    <?php } ?>

                </select>
                <p><?php _e( 'This field is optional', 'msd' ); ?></p>
            </div>
            <div class="clearfix"></div>
        </div>

What am i missing?

You can’t use conditional logic on select event using PHP. Either you need to get all select & options and show them conditionally (not preferred way)

OR

You need to add AJAX call on first select box change.

Follow this:

/* first select box */
<select id="select_d" name="<?php echo esc_attr( $this->get_field_name( 'selezionato' ) ); ?>">
            <option class="sd">select</option>
            <option value="taxonomy_slug_1">Taxonomy 1</option>/*use as same as you done above.*/
            <option value="taxonomy_slug_2">Taxonomy 2</option>
            <option value="taxonomy_slug_3">Taxonomy 3</option>
        </select>
        <div class="resresult"></div>

/*JQuery for getting taxonomy on change event*/
    <script type="text/javascript">

    jQuery('#select_d').on('change', function(){
        var tax = jQuery("#select_d").val();
        alert(tax)
        jQuery.ajax({
            url: myScript.ajax_url,
            type: "POST",
            data: {
                action: 'get_more_select',
                tax: tax,
            },
            success: function(response){
                 console.log(response)
                jQuery('.resresult').html(response);
            }
        });
    })
        </script>

    /*Enqueue your script (if not added)*/

add_action('wp_enqueue_scripts','ajaxlar_js_fn');
function ajaxlar_js_fn() {


            wp_enqueue_script( 'ajaxlar_js', plugins_url( '/js/custom.js', __FILE__ ), true);
             wp_localize_script('ajaxlar_js', 'myScript', array(
            'ajax_url' => admin_url( 'admin-ajax.php' ),
            ));
        }

/*Finally get the result and return to blank div we had created after first select box*/
 add_action('wp_ajax_nopriv_more_posts', 'get_more_select');

            function get_more_select(){

               $tax =  $_POST['tax'];

               $terms = get_terms( array(
                'taxonomy' => $tax,
                'hide_empty' => false,
                ) );

               $html = "";
               $html .= "<select>";
               $html .= "<option>select</option>";
               foreach ($terms as $value) {
                    $html .= "<option value='".$value->slug."'>".$value->slug."</option>";
               }
               $html .= "</select>";

               return $html;

                exit(); 
            }

Hope this help. (This is tested code on my system)
Thanks.