Home > Web Front-end > JS Tutorial > body text

js fuzzy query example sharing

高洛峰
Release: 2017-01-16 09:32:46
Original
1204 people have browsed it

First of all, you must understand what a fuzzy query is (nonsense again), which is to list one or more items in the list that match the keyword based on the keyword, that is, to check whether each item in the list contains the keyword. , so abstractly it means whether a string contains a certain character or string.

The following example does not have any knowledge of background data, but only queries the keywords contained in each row in the current table.

The method used is: string.indexOf(''); to find the position of a certain character in the string, and -1 will be returned if there is no target character.

Implementation code:

<meta charset="UTF-8">
<title></title>
<table id="Result1">
  <tbody><tr>
    <th></th>
    <th>账户名称</th>
    <th>账户</th>
    <th>户名简称</th>
    <th>开户行号</th>
    <th>开户行名称</th>
    <th></th>
  </tr>
  <tr class="dim-check">
    <td></td>
    <td><input type="text" maxlength="50" id="accountNameStr" name="1" value=""></td>
    <td><input type="text" maxlength="50" id="accountNoStr" name="2" value=""></td>
    <td><input type="text" maxlength="50" id="accountShortStr" name="3" value=""></td>
    <td><input type="text" maxlength="50" id="branchBankNoStr" name="4" value=""></td>
    <td><input type="text" maxlength="50" id="branchBankNameStr" name="5" value=""></td>
  </tr>
  <tr>
    <td><input type="radio" name="accounts" value="634"></td>
    <td>安顺账号1</td>
    <td>060156300000123</td>
    <td>简称123</td>
    <td>31375635312</td>
    <td>中国银行股份有限公司</td>
  </tr>
  <tr>
    <td><input type="radio" name="accounts" value="634"></td>
    <td>安顺账号2</td>
    <td>0601001100000123</td>
    <td>安顺账号2-简称123</td>
    <td>3137565012</td>
    <td>南京银行股份有限公司</td>
  </tr>
  <tr class="">
    <td><input type="radio" name="accounts" value="634"></td>
    <td>安顺账号3</td>
    <td>0601001154520123</td>
    <td>安顺账号215</td>
    <td>38968599012</td>
    <td>建行有限公司</td>
  </tr>
</tbody></table>
Copy after login

The above is the entire content of this article. I hope that the content of this article can bring some help to everyone's study or work. I also hope to support the PHP Chinese website!

For more js fuzzy query examples and related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template