I have a table where each row is an address. Each row has, as well, a zip code but it’s hidden.
I need a textbox to filter the address rows that matches with the zip entered. The field to search is named as “zip”.
Here’s my table:
<asp:DataList
id="list1"
runat="server">
<ItemTemplate>
<cc1:SWCLabel
runat="server"
Text ='<%# Eval("address")%>'
zip='<%# Eval("zip")%>'
/>
</ItemTemplate>
Each table rows is rendered like this, note the zip attribute into the span:
<tr>
<td>
<span zip="11">address mmomo</span>
</td>
</tr>
UPDATED DEMO:
Here’s the demo: The zip textbox matches the zip entirely but I need that matches zips that contains or starts with the text entered:
http://jsfiddle.net/QFQ5k/83/
Update
If you’re sure that any one of the child elements of the row contains the attribute “zip” then use this to filter the rows regardless of their rendering:
instead of
return $(this).find("span").attr("zip").search($("#txtbox").val())!=-1;write
return $(this).find("[zip*='"+$("#txtbox").val()+"']").length>0;Check it here: http://jsfiddle.net/QFQ5k/89/