Handling Select option in PHP in case of many drop-down menu

In the following code, I am trying to handle the select option or the value of the text field:\[code\]<script>function check() { var dropdown = document.getElementById("OpType"); var current_value = http://stackoverflow.com/questions/15873563/dropdown.options[dropdown.selectedIndex].value; if (current_value =="OpNo") { document.getElementById("operationno").style.display = "block"; document.getElementById("MainType").style.display = "none"; document.getElementById("MemName").style.display = "none"; document.getElementById("EmpName").style.display = "none"; <?php $TPE = '1'?> } else if (current_value =http://stackoverflow.com/questions/15873563/="OpTyp") { document.getElementById("MainType").style.display = "block"; document.getElementById("MemName").style.display = "none"; document.getElementById("EmpName").style.display = "none"; document.getElementById("operationno").style.display = "none"; <?php $TPE = '2'?> } else if (current_value =http://stackoverflow.com/questions/15873563/="OpMem") { document.getElementById("MemName").style.display = "block"; document.getElementById("operationno").style.display = "none"; document.getElementById("MainType").style.display = "none"; document.getElementById("EmpName").style.display = "none"; <?php $TPE = '3'?> } else if (current_value =http://stackoverflow.com/questions/15873563/="OpEmp"){ document.getElementById("MemName").style.display = "none"; document.getElementById("operationno").style.display = "none"; document.getElementById("MainType").style.display = "none"; document.getElementById("EmpName").style.display = "block"; <?php $TPE = '4'?> } else if (current_value =http://stackoverflow.com/questions/15873563/="blank") { document.getElementById("MainType").style.display = "none"; document.getElementById("MemName").style.display = "none"; document.getElementById("EmpName").style.display = "none"; document.getElementById("operationno").style.display = "none"; <?php $TPE = '0'?> }}</script><form name="f1" action="FollowOperations.php" method="post"><select id="OpType" onChange="check();"><option value="http://stackoverflow.com/questions/15873563/blank">Choose</option><option value="http://stackoverflow.com/questions/15873563/OpNo">Operation No</option><option value="http://stackoverflow.com/questions/15873563/OpTyp">Operation Type</option><option value="http://stackoverflow.com/questions/15873563/OpMem">Maintenance Member</option><option value="http://stackoverflow.com/questions/15873563/OpEmp">Employee</option></select><br><input class="tb10" type="text" id="operationno" size="4" style="text-align: center" style="display: none"> <select id="MainType" style="display: none"><option value="http://stackoverflow.com/questions/15873563/blank">Choose</option><option value="http://stackoverflow.com/questions/15873563/printing">Printing</option><option value="http://stackoverflow.com/questions/15873563/maintenance">PC Maintenance</option><option value="http://stackoverflow.com/questions/15873563/internet">Internet Problem</option><option value="http://stackoverflow.com/questions/15873563/software">Software</option><option value="http://stackoverflow.com/questions/15873563/email">Email Problem</option><option value="http://stackoverflow.com/questions/15873563/usbcd">USB/CD Problem</option></select><select id="MemName" style="display: none"><option value="http://stackoverflow.com/questions/15873563/blank">Choose</option><option value="http://stackoverflow.com/questions/15873563/john">John</option><option value="http://stackoverflow.com/questions/15873563/hen">Hen</option></select> <select id="EmpName" style="display: none"><option value="http://stackoverflow.com/questions/15873563/blank">Choose</option><option value="http://stackoverflow.com/questions/15873563/smith">Smith</option><option value="http://stackoverflow.com/questions/15873563/will">William</option><option value="http://stackoverflow.com/questions/15873563/Gor">George</option></select><input type="submit" value="http://stackoverflow.com/questions/15873563/Submit" class="button" /> </form><?phpif (isset($_POST['formsubmitted'])){if ($TPE == '1'){$operationno = $_POST['operationno'];$query_retrieve_maintenance = "Select Type from Maintenance where ID = '$operationno'";$result_retrieve_maintenance = mysqli_query($dbh, $query_retrieve_maintenance);$maintenance_type = mysqli_fetch_row($result_retrieve_maintenance);$maintenance_typet = $maintenance_type[0];echo $maintenance_typet;} else if ($TPE == '2'){$MainType = $_POST['MainType'];if ($MainType=='email'){echo 'Email is not ava';}} else if ($TPE == '3'){$MemName = $_POST['MemName'];} else if ($TPE == '4'){$EmpName = $_POST['EmpName'];} else{$msg = 'not available';}}?>\[/code\]As you can see in the code, when a user selects operation no, a text field will show up and then the user will enter the operation no to show the type of this maintenance operation. Similarly, when the user selects operation type, the list of maintenance types will show up so that the user selects the type of the operation that he needs and so on for the rest of select options. The problem that I am facing is handling what the user selects or enters (in case of searching by operation no). As you can see in the code, I used \[code\]if (isset($_POST['formsubmitted'])){\[/code\] but it didn't work. Any suggestions guys.
 
Back
Top