1

I have a function named as "getSelectValue(this.value)" that gets executed on changing the select options.I want to somehow use this value inside the next select tag.is it possible?

 if($res = $mysqli->query($sql))
            {

                echo '
                            <select id="profession" name="profession" onchange="getSelectValue(this.value);">';
                            $f1=1;
                            echo'<option selected="true" disabled="disabled">Filter by Profession</option> ';              
                while ($row = $res->fetch_assoc()) {
                     echo "<option value='" . $row['Designation'] ."'>" . $row['Designation'] ."</option>";
                }
                echo '</select>';
                $res->free();
              
            }     
            $ids = "SELECT DISTINCT `Identifies As` FROM `therapists`";
            if($res = $mysqli->query($ids))
            {
                if($f1==0)
                {
                    echo '<select id="idas"  name="idas" onchange="getSelectValue(this.value);">
                    <option selected="true" disabled="disabled">Identifies as</option> ';
                    while ($row = $res->fetch_assoc()) {
                        echo "<option value='" . $row['Identifies As'] ."'>" . $row['Identifies As'] ."</option>";
                    } 
                    echo '</select>';
                    $res->free();
                }
                else{
                     //this.value to be used here
                }
            }

I want to access the this.value(under profession id) at the else part of the next select tag.

Sachin Jadhav
  • 114
  • 1
  • 8
  • Possible duplicate. Please check: https://stackoverflow.com/questions/19728666/drop-down-box-dependent-on-the-option-selected-in-another-drop-down-box – Hisham Jul 18 '21 at 13:10

0 Answers0