我正在尝试将一个jQuery下拉过滤器添加到要从数据库中提取的表中
我提到了一些类似的问题,并从其中一个获得了代码。我可以使下拉前端正常工作,但会卡在后端。
report.php
/^(0?[1-9]|1[0-2][h])([1-6][0-9][m])([1-6][0-9][s])\d$/.test('2d1h10m10s')
/^(0?[1-9]|1[0-2][h])([1-6][0-9][m])([1-6][0-9][s])\d$/.test('10m10s')
/^(0?[1-9]|1[0-2][h])([1-6][0-9][m])([1-6][0-9][s])\d$/.test('10s')
main.js
<div id="container">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<label for="filter">Gender:</label>
<select class="filter" data-tableId="myTable">
<option value="all">All</option>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
<body>
<i style="font-size:24px" class="fa"></i>
</body>
</html>
<div class="table-responsive">
<table id ="myTable" class="table table-striped">
<thead>
<tr>
<th> First Name </th>
<th> Last Name </th>
<th> Phone </th>
<th> Email </th>
<th> Gender </th>
<th> Action </th>
</tr>
</thead>
<?php
if (count($report) === 0) {
echo "<tr>No Reports</tr>";
} else {
for ($i = 0; $i < count($report); $i++) {
echo
"<tr>
<td>{$report[$i]['FName']}</td>
<td>{$report[$i]['LName']}</td>
<td>{$report[$i]['HPhone']}</td>
<td>{$report[$i]['PEmail']}</td>
<td>{$report[$i]['Gender']}</td>
<td><a class=btn href='read.php?id=".$report[$i]['RegId']."'>Read</a></td>
</tr>";
}
}
?>
</table>
</div>
我想将过滤器放在表格的性别列上。
我确定main.js中存在一些错误,并且已经尝试了一段时间,但找不到。我是jquery新手,任何帮助将不胜感激。 TIA
答案 0 :(得分:0)
df_wt.set_index('Name', inplace=True)
df_sc.set_index('Name', inplace=True)
mask = df_wt['Weight'].ne(0)
common_index = df_wt.loc[mask, :].index
df_wt.loc[common_index, 'Weight'].corr(df_sc.loc[common_index, 'Score'])
0.923425144491911
答案 1 :(得分:0)
您可以使用AJAX处理此任务。
HTML代码:
<form name="formobject" method="POST" action="">
<input type="hidden" name="formrstatus" value="">
<select class="filter" data-tableId="myTable" onchange="checkValue(this.value)">
<option value="all">All</option>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</form>
<script>
</script>
function checkValue(id){
$.ajax({
type: "POST",
url:"/someurl",
dataType: 'JSON',
data: {id},
success: function(response) {
//use this response to fetch table data
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
}
});
}
/*Use api to fetch the values according to the posted value and return the json encoded value, something like this*/
<?php
$id=encodestring($_POST["id"]);
$sql="select * from sometable where gender='".$id."'";
$result= $mysqli->query($sql);
$vars[] = array($res);
echo json_encode($vars);
?>