This is what you do before you make a query on a Web page.
Form get keyword –> incoming back-end SQL statement processing –> data back to front display
Today suddenly to the ctrl+f of the browser how to achieve this function, the data once on the page, and then use JS to match the content of the page.
Anyway, now that you've done the function, and then you're doing the optimization
Copy Code code as follows:
$ (function () {
var userarray = new Array ();
var turenamearray = new Array ();
var table = $ ("Table>tbody");
Table.children (). each (function () {
UserID = $ (this). Children (). EQ (0). html ();
To deposit the number in the output
Userarray.push (userid);
Turename = $ (this). Children (). EQ (1). html ();
Save the name in an array
Turenamearray.push (Turename);
});
//
$ ("#search"). focus (function () {
$ (this). Val ("");
}). blur (function () {
val = $.trim ($ (this). Val ());
if (val = = "")
{
$ (this). Val ("Work Number/name");
}
});
$ (". Btn"). Click (function () {
val = $ ("#search"). Val ();
if (val = = "Work number/name")
{
Alert ("Please enter a valid work number and name");
}
Else
{
Table.children (). Hide ("100");
if (!isnan (val))
{
HANLD (Userarray,val);
}
Else
{
HANLD (Turenamearray,val);
}
}
});
function hanld (array,value)
{
for (i=0;i<array.length;i++)
{
if (Array[i].indexof (value)!==-1)
{
Table.children (). EQ (i)-Show ("1000");
}
}
}
The code is above, I'll say the design idea below.
Get the data that you want to match into the array in order, and then match it.
The function that locates with the substring of JS IndexOf if does not match returns 1, the match returns the position of the string.
This will allow you to complete the search. The first is to hide all the data and then the matching success is displayed. That's OK.