php - How to hide previous table rows that were shown based on previous search -
the idea of following code user search based on maintenance operation no, operation type, member performs operation, or employee pc needs maintenance. when user selects, example, operation type, drop-down menu show , selects type. after table of maintenance information show up. example, user selects type printing. table show following information:
operation no, member name, employee name, maintenance type
1001, adem, john, printing 1003, george, smith, printing 1010, william, john, printing
the problem facing when user selects search operation no, example, , selects operation no 1001, rest of rows (1003 , 1010 shown based on previous search) still shown (they must hidden because not match search type).
the code is
<script> function check() { var dropdown = document.getelementbyid("optype"); var current_value = 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"; } else if (current_value == "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"; } else if (current_value == "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"; } else if (current_value == "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"; } else if (current_value == "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"; } } </script> <form name="f1" action="followoperations.php" method="post"> <select id="optype" onchange="check();"> <option value="blank">choose</option> <option value="opno">operation no</option> <option value="optyp">operation type</option> <option value="opmem">maintenance member</option> <option value="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="blank">choose</option> <option value="printing">printing</option> <option value="maintenance">pc maintenance</option> <option value="internet">internet problem</option> <option value="software">software</option> <option value="email">email problem</option> <option value="usbcd">usb/cd problem</option> </select> <select id="memname" style="display: none"> <option value="blank">choose</option> <option value="john">john</option> <option value="hen">hen</option> </select> <select id="empname" style="display: none"> <option value="blank">choose</option> <option value="smith">smith</option> <option value="will">william</option> <option value="gor">george</option> </select> <input type="submit" value="submit" class="button" /> </form> <?php if (isset($_post['formsubmitted'])) { $operationno = $_post['ono']; echo "<table id='tfhover' class='tftable' border='1' align='center'>"; echo "<tr align='center'><th></th><th align='center'>type</th><th>employee</th><th align='center'>member</th><th align='center'>operation no</th></tr>"; $query_retrieve_maintenance = "select * maintenance id = '$operationno'"; $result_retrieve_maintenance = mysqli_query($dbh, $query_retrieve_maintenance); while($row1 = mysqli_fetch_array($result_retrieve_maintenance)) { echo "<tr>"; echo "<td><a href='pastoperationsdet.php?operation_number=".$row1['id']."' target='_blank'>show</a></td> "; echo "<td>".$row1['type']."</td> "; echo "<td>".$row1['memname']."</td> "; echo "<td>".$row1['empname']."</td> "; echo "<td>".$row1['id']."</td> "; } $maintype = $_post['mt']; $query_retrieve_by_type = "select * maintenance type = '$maintype'"; $result_retrieve_by_type = mysqli_query($dbh, $query_retrieve_by_type); while($row1 = mysqli_fetch_array($result_retrieve_by_type)) { echo "<tr>"; echo "<td><a href='pastoperationsdet.php?operation_number=".$row1['id']."' target='_blank'>show</a></td> "; echo "<td>".$row1['type']."</td> "; echo "<td>".$row1['memname']."</td> "; echo "<td>".$row1['empname']."</td> "; echo "<td>".$row1['id']."</td> "; } $memname = $_post['mn']; $query_retrieve_by_member = "select id member name = '$memname'"; $result_retrieve_by_member = mysqli_query($dbh, $query_retrieve_by_member); $membid = mysqli_fetch_row($result_retrieve_by_member); $memb_id = $membid[0]; $query_retrieve_by_membername = "select * maintenance memberid = '$memb_id'"; $result_retrieve_by_membername = mysqli_query($dbh, $query_retrieve_by_membername); while($row1 = mysqli_fetch_array($result_retrieve_by_membername)) { echo "<tr>"; echo "<td><a href='pastoperationsdet.php?operation_number=".$row1['id']."' target='_blank'>show</a></td> "; echo "<td>".$row1['type']."</td> "; echo "<td>".$memb_id."</td> "; echo "<td>".$row1['empname']."</td> "; echo "<td>".$row1['id']."</td> "; } $empname = $_post['me']; $query_retrieve_by_employee = "select id employee name = '$empname'"; $result_retrieve_by_employee = mysqli_query($dbh, $query_retrieve_by_employee); $emplid = mysqli_fetch_row($result_retrieve_by_employee); $empl_id = $emplid[0]; $query_retrieve_by_emplid = "select * maintenance employeeid = '$empl_id'"; $result_retrieve_by_emplid = mysqli_query($dbh, $query_retrieve_by_emplid); while($row1 = mysqli_fetch_array($result_retrieve_by_emplid)) { echo "<tr>"; echo "<td><a href='pastoperationsdet.php?operation_number=".$row1['id']."' target='_blank'>show</a></td> "; echo "<td>".$row1['type']."</td> "; echo "<td>".$row1['memname']."</td> "; echo "<td>".$empl_id."</td> "; echo "<td>".$row1['id']."</td> "; } echo "</table>"; } ?>
nass,
i took liberty make fiddle case. take @ , ask if don't understand it.
i hope helps.
kind regards, alex
in link, http://jsfiddle.net/qthb6/10/, it's set in clean way, like;
function blockify () { // style.display = "block" } function unblockify () { // style.display = "none" }
Comments
Post a Comment