2015-02-10 60 views
0

()函数也有.show,它在那里工作,但如果else语句中,.show()不工作的其余部分。我.show()不工作,但.hide工作在调用getRequest

function bySubject(subject){ 
    if (subject != "All" && subject != "user-2") { 
     getRequest(subject); 
    } 
    else if(subject == "user-2"){ 
     $("tr.req-row").hide(); 
     $("tr.user-2").show(); 
    } 
    else{ 
     $("tr.req-row").show(); 
    } 
} 

我该如何解决这个问题?我不认为语法有什么问题,是吗?

编辑:HTML代码ADDED

//dropdown where i get the value of subject 
if ($subject_numrows > 0) { 
        $subjects = $function->select_result($link, $subject_query); 
      ?> 
        <table> 
         <tr> 
          <td><label for="select-subject" >View by: </label></td> 
          <td> 
           <select name="select-subject" id="select-subject" class="form-control" onchange="bySubject(this.value)"> 
             <option value="All">All</option> 
             <?php 
              foreach ($subjects as $value) { 
             ?> 
               <option value="<?php echo $value['SubjectName']; ?>"><?php echo $value['SubjectName']; ?></option> 
             <?php  
              } 
             ?> 
             <option value="user-3">Other Dept./Org.</option> 
           </select> 
          </td> 
         </tr> 
        </table> 
      <?php 
       } 
      ?> 

//table to display the result. 
<table class="table table-striped table-bordered responsive"> 
       <tr> 
        <th class="req-th"><center>Today's Requests<center></th> 
       </tr> 
       <tbody> 
       <?php 
         if ($req_numrows > 0) { 

         $request_details = $function->select_result($link, $request_query); 

          foreach ($request_details as $value) { 
           $req_id = $value['Request_ID']; 
           $userid = $value['User_ID']; 
           $status = $value['Request_Status']; 
           $sqldate = $value['Date_Needed']; 
           $date = strtotime($sqldate); 

           $query = "SELECT * FROM usertbl WHERE User_ID='$userid'"; 
           $result = mysqli_query($link, $query); 
           $user_row = mysqli_fetch_array($result); 
           $usertype = $user_row['UserType']; 
           /*if ($status == "PENDING" || $status == "NOTED" || $status == "CHECKED") { 
            $status_class = "label-warning label label-default"; 
           } 
           if ($status == "APPROVED") { 
            $status_class = "label-success label label-default"; 
           }*/ 
           if (date("F j, Y", $date) == date("F j, Y")) { 
            echo "<tr class='req-row " . $status . " " . $usertype . "' id='" . $req_id . "'><td><table class='table'>"; 


            echo "<tr><td class='center name' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'> 
               <label>ID No:</label>&nbsp&nbsp" . $value['User_ID'] . " 
              </td></tr>"; 
            echo "<tr><td class='center name' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'> 
               <label>Name:</label>&nbsp&nbsp" . $user_row['UserName'] . " 
              </td></tr>"; 

            if ($usertype == "user-2") { 
             echo "<tr>"; 
             echo "<td class='center' style='border: 0 none;padding-top: 0px; padding-bottom: 0px; width: 500px'><label>Subject:</label>&nbsp&nbsp" . $value['Subject'] . "</td>"; 

             $profid = $value['Prof_ID']; 
             $query = "SELECT * FROM usertbl WHERE User_ID='$profid'"; 
             $result = mysqli_query($link, $query); 
             $prof_row = mysqli_fetch_array($result); 
             echo "<td class='center' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'><label>Professor:</label>&nbsp&nbsp" . $prof_row['UserName'] . "</td>"; 
             echo "</tr>"; 
            } 
            else{ 
             echo "<tr>"; 
             echo "<td class='center' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'><label>Purpose:</label>&nbsp&nbsp" . $value['Purpose'] . "</td>"; 
             echo "</tr>"; 
            } 

             echo "<tr><td class='center' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'><label>Date Needed:</label>&nbsp&nbsp" . date("F j, Y", $date) . "</td>"; 
             echo "<td class='center' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'><label>Time Needed:</label>&nbsp&nbsp" . date("g:i a", strtotime($value['fromTime_Needed'])) . " to " . date("g:i a", strtotime($value['toTime_Needed'])) . "</td></tr>"; 
             echo "<tr><td colspan='2'>"; 
               echo "<button class='btn btn-danger viewbtn pull-right' href='' id=" . $value['Request_ID'] . "><i class='glyphicon glyphicon-ok icon-white'></i> 
                 Release Equipments</button>"; 
              echo "</td></tr>"; 
             echo "</table></td</tr>"; 
           } 
          } 
         } 
         else{ 
          echo "<tr><td colspan='6'><center>No Request to display.</center></td></tr>"; 
         } 
       ?> 
       </tbody> 
      </table> 
+2

显示你的HTML代码 – user2232273 2015-02-10 12:38:00

+0

你可能包括HTML? – 2015-02-10 12:38:06

+0

没有足够的信息来识别问题 – chim 2015-02-10 12:38:17

回答

0

你把空格,而要添加类名TR。