如何解决下拉列表值不过滤表
当用户在“帐户”或“发票”框中键入一些值以在表中进行搜索时,则一切正常。但是,当我添加代码行以通过下拉值进行其他过滤时,它行不通。表格中要过滤的数据在第6列中。没有返回任何行:
查看:
<th>
<p>
Nr account: @Html.TextBox("Account")
<input type="button" class="search" value="Search" />
</p>
<p>
Nr invoice: @Html.TextBox("Invoice")
<input type="button" class="search" value="Search" />
</p>
<p>
@Html.DropDownList("filterList",new List<SelectListItem>
{
new SelectListItem { Text="",Value= "",Selected=true},new SelectListItem { Text="Cancellation",Value="Cancellation"}
})
<input type="button" class="search" value="Filter data" />
</p>
</th>
jQuery:
$('.search').click(function () {
var value1 = $("#Account").val().toLowerCase();
var value2 = $("#Invoice").val().toLowerCase();
var value3 = $("#filterList:selected").val(); //value od seleted item (or not selected if I don't choose anything)
$("#myTable tr").filter(function () {
var text1 = $(this).children(":eq(" + "0" + ")").text().toLowerCase() //search values in 1st column
var text2 = $(this).children(":eq(" + "2" + ")").text().toLowerCase()
var text3 = $(this).children(":eq(" + "5" + ")").text()
$(this).toggle((text1.indexOf(value1) > -1) && (text2.indexOf(value2) > -1) && (text3.indexOf(value3) > -1))
});
});
似乎常规的TextBoxes在这里不与DropDownList合作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。