如何使用Multiselect List在表格中创建过滤搜索结果

时间:2015-12-22 00:05:25

标签: javascript php html

如何编辑此代码以使其适用于多选下拉列表

以下是显示列表的代码

<select name="size1" multiple="multiple" id="ddYear" class="form-control   input-sm">
<option value="">Select Manufacturers</option>
<?php
   $record = mysqli_query($con,"SELECT DISTINCT Manufacturer FROM db WHERE Manufacturer in ('A', 'B', 'C', 'D', 'E', 'F')  ORDER BY Manufacturer ASC");
   while ($row = mysqli_fetch_array($record)) {
echo "<option value='" . $row['Manufacturer'] . "'>" . $row['Manufacturer'] . "</option>";
   }
                                                                           ?>

// Js代码

 <script type="text/javascript">
 var $rows = $('#dataTables-example2 tbody tr');
   $('#ddYear').change(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>

0 个答案:

没有答案