我有以下代码我想要更多地搜索搜索结果/使用下拉框中的值缩小表格中的搜索结果。我可以使用文本框进行搜索,但我还想使用下拉值
过滤更多搜索结果//下拉
<select name="size1" id="search" class="form-control" style=" width: 200px;font-family: Abel;font-weight: 900;font-size: 15px;color:#000; background: #fff" >
<option value="">Select Size</option>
<option value="val1">Val1</option>
<option value="val2">Val2</option>
<option value="val3">Val3</option>
</select>
// textbox
<label id="lbl_auto_year" for="auto_year" class="" >Narrow your Search by Man<br/>
<input value="" class="form-control input-sm" autocomplete="off" name="txttreadd" id="search" style="width:200px;color:#000;background:#fff" type="text">
//显示结果的PHP代码
echo'<table class="table table-striped table-bordered table-hover" id="dataTables-example" ><tbody>';
$record = mysqli_query($con,"SELECT * FROM table_name ORDER BY Manufacturer");
while ($row = mysqli_fetch_array($record)) {
if($row['RC']!="" && $row['SW']!="")
{
if($ag=="" && $size1=="" && $size=="" && $lcc=="" && $scc=="" && $smallsw=="" && $largesw=="" && $smallrc=="" && $largerc=="" && $txtsize=="" && $small== "" && $large == "")
{
}
elseif ($row['Tread_Design']==$R1W)
{
echo "<tr>";
//echo "<td style=' width:300px;text-align:left; padding-left: 10px;vertical-align: middle;'>";echo $row['Manufacturer'];echo"</td>";
echo "<td style=' width:150px; text-align:left; padding: 10px;vertical-align: middle;'>";echo $row['Brand_Name'];echo"</td>";
echo "<td style='width:110px; text-align:left; vertical-align: middle;'>";echo $row['Tire_Size'];"</td>";
echo "<td style='width:100px; text-align:left; vertical-align: middle;'>";echo $row['SW'];"</td>";
echo "<td style='width:100px; text-align:left;vertical-align: middle;'>";echo $row['OD'];"</td>";
echo '</tr></tbody></table>';
}
}......
这是使用文本框时可以使用的JS代码。我怎样才能让它适用于下拉列表
<script type="text/javascript">
var $rows = $('#dataTables-example2 tbody tr');
$('#search').keyup(function() {
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
$rows.show().filter(function() {
var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
</script>