在getRequest()函数中还有一个.show,它在那里工作,但在if else语句的其余部分,.show()不起作用。
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代码
//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>  " . $value['User_ID'] . "
</td></tr>";
echo "<tr><td class='center name' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'>
<label>Name:</label>  " . $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>  " . $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>  " . $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>  " . $value['Purpose'] . "</td>";
echo "</tr>";
}
echo "<tr><td class='center' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'><label>Date Needed:</label>  " . date("F j, Y", $date) . "</td>";
echo "<td class='center' style='border: 0 none;padding-top: 0px; padding-bottom: 0px;'><label>Time Needed:</label>  " . 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>
答案 0 :(得分:0)
在将类名添加到tr时,您将放置空格。