如何显示从输入文本字段获取的以下代码的值?

Hye! can anyone help. I'm stuck already. I want to display the value that I got from the text field for the following code. Oh!!! the $str in the code actually is the value that I got from the dropdown option.

So actually I'm trying to have a dropdown button on the page which is when the user select a value at first dropdown, another dropdown menu / text box will display. As the codes below, different value may have different display for the next display either dropdown OR text box. So now i'm trying to get the value from the next displayed dropdown OR text box. so for now i'm trying to get the value from the text box that displayed after selection from the first dropdown.

Hope this will be clear :)

Thanks for helping

<form name="nameOfForm" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" action="search_handler">
                    <div class="row">
                        <div class="col-md-4">
                        <?php 
                            echo "<b>Search By : </b><br>";
                            echo "<select class='inputStyle' name='option' onchange='this.form.submit();'>";
                            echo "<option value=''>--Please Select--</option>";
                            echo "<option value='RefNo'>Reference No</option>";
                            echo "<option value='Date'>Date</option>";
                            echo "<option value='Requestor'>Requestor</option>";
                            echo "<option value='Type'>Type</option>";
                            echo "</select>";
                        ?>
                        </div>
                        <div class="col-md-4">
                        <?php
                            $str='';
                            $maxDate = date("d-m-Y");//todays date
                            //echo $maxDate; 

                            if($_GET){
                                //echo $_GET['option'];
                                $str = $_GET['option'];
                                //echo $str;
                            }
                            if ($str != ''){
                                if ($str == "RefNo"){
                                    //echo "Hello!";
                                    echo "<b>Type Reference No. Here :</b><br>";
                                    echo "<input class='inputStyle' id='RefNo' name='RefNo' type='text' autocomplete='off' required>";
                                }else if ($str == "Requestor"){
                                    //echo "Hello!";
                                    echo "<b>Type Requestor Name Here :</b><br>";
                                    echo "<input class='inputStyle' id='ReqName' name='ReqName' type='text' autocomplete='off' required>";
                                }else if($str == "Type"){
                                    echo "<b>Choose Type :</b><br>";
                                    echo "<select class='inputStyle' name='type'>";
                                    echo "<option value=''>--Please Select--</option>";
                                    echo "<option value='PETTY CASH'>Petty Cash</option>";
                                    echo "<option value='OTHERS'>Others</option>";
                                    echo "</select>";
                                }else{
                                    //echo "Date Here!";
                                    echo "<b>From</b><br>";
                                    echo "<input class='inputStyle' onchange='allowToDate()' id='from' name='from' type='date' max='<?php echo $maxDate; ?>' required>";
                                    echo "<b>To</b><br>";
                                    echo "<input class='inputStyle' id='to' name='to' type='date' max='<?php echo $maxDate; ?>' required disabled>";
                                }
                            }
                            else {
                            echo "</br>";
                            echo "Please Select A Value From Dropdown!";
                            }
                        ?>
                        </div>
                        <div class="col-md-2">
                            <br>
                            <input class="submitBtnBS" type="button" onclick="search()" id="proceed" name="proceed" value="PROCEED" style="height:35px; width:100%;">
                        </div>
                        <div class="col-md-2">
                            <br>
                            <input class="clearBtnBS" type="button" onClick="clearForm(this.form)" id="clear" name="clear" value="CLEAR" style="height:35px; width:100%;">
                        </div>
                    </div>
            </form>

You should create a form (with post or get method). Then when the form is send to your page you can get the inputed value.

Your code modified:

<form name="nameOfForm" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" action="search_handler">
                <div class="row">
                    <div class="col-md-4">
                    <?php 
                        echo "<b>Search By : </b><br>";
                        echo "<select class='inputStyle' name='option' onchange='this.form.submit();'>";
                        echo "<option value=''>--Please Select--</option>";
                        echo "<option value='RefNo'>Reference No</option>";
                        echo "<option value='Date'>Date</option>";
                        echo "<option value='Requestor'>Requestor</option>";
                        echo "<option value='Type'>Type</option>";
                        echo "</select>";
                    ?>
                    </div>
                    <div class="col-md-4">
                    <?php
                        $str='';
                        $maxDate = date("d-m-Y");//todays date
                        //echo $maxDate; 

                        if($_GET){
                            //echo $_GET['option'];
                            $str = $_GET['option'];
                            //echo $str;
                        }
                        if ($str != ''){
                            if ($str == "RefNo"){
                                //echo "Hello!";
                                echo "<b>Type Reference No. Here :</b><br>";
                                echo "<input class='inputStyle' id='RefNo' name='RefNo' type='text' autocomplete='off' required>";
                            }else if ($str == "Requestor"){
                                //echo "Hello!";
                                echo "<b>Type Requestor Name Here :</b><br>";
                                echo "<input class='inputStyle' id='ReqName' name='ReqName' type='text' autocomplete='off' required>";
                            }else if($str == "Type"){
                                echo "<b>Choose Type :</b><br>";
                                echo "<select class='inputStyle' name='type'>";
                                echo "<option value=''>--Please Select--</option>";
                                echo "<option value='PETTY CASH'>Petty Cash</option>";
                                echo "<option value='OTHERS'>Others</option>";
                                echo "</select>";
                            }else{
                                //echo "Date Here!";
                                echo "<b>From</b><br>";
                                echo "<input class='inputStyle' onchange='allowToDate()' id='from' name='from' type='date' max='<?php echo $maxDate; ?>' required>";
                                echo "<b>To</b><br>";
                                echo "<input class='inputStyle' id='to' name='to' type='date' max='<?php echo $maxDate; ?>' required disabled>";
                            }
                        }
                        else {
                        echo "</br>";
                        echo "Please Select A Value From Dropdown!";
                        }
                    ?>
                    </div>
                    <div class="col-md-2">
                        <br>
                        <input class="submitBtnBS" type="button" onclick="search()" id="proceed" name="proceed" value="PROCEED" style="height:35px; width:100%;">
                    </div>
                    <div class="col-md-2">
                        <br>
                        <input class="clearBtnBS" type="button" onClick="clearForm(this.form)" id="clear" name="clear" value="CLEAR" style="height:35px; width:100%;">
                    </div>
                </div>
        </form>
<?php
    if(isset($_GET["RefNo"])){
        echo $_GET["RefNo"];
    }
    if(isset($_GET["ReqName"])){
        echo $_GET["ReqName"];
    }
?>

In your HTML File:

<form action="yourphpfile.php" method="get">
<select name="RefNo" id="RefNo" required class="">
   <option value="">Choose one</option>
   <option>List 1</option>
   <option>List 2</option>
   <option>List 3</option>
   <option>List 4</option>
</select>
<input type='submit' value='submit' name='submit' />
</form>

In your PHP:

<?php
//To prevent having "Undefined index" warnings, you need to check if GET is the request method 
if ($_SERVER['REQUEST_METHOD'] == "GET"){
$str = $_GET['RefNo'];
..
..
..
..
..
}
?>