Autocomplete automatic match, linkage Input

Source: Internet
Author: User

There are some basic information about employees in the database. When users enter existing employee information, they often want to automatically match the input content like Baidu and Google search. Once the match succeeds, other information is automatically entered, you do not need to lose any more. You can use the jquery. autocomplete plugin. For example, the database contains the following information: phone number, ID card number, and name. When you enter any information, you want to automatically complete the matching. After the matching is successful, the other two information is automatically entered. Import <link rel = "stylesheet" type = "text/css" href = ".. /public/jquery.autocomplete.css "/> <script type =" text/javascript ">$ (function () {// receives the json var json1 = eval ("(" + $ ("# aujson1") of the background "). val () + ")"); // match the phone number $ ("# iPhone "). autocomplete (json1.data, {formatItem: function (item) {return item. phone; // The value displayed in the current input box }}). result (function (event, item) {$ ("# iCard "). val (item. shenFen); $ ("# iName "). val (item. xingMing ); }); // Match your ID card $ ("# iCard "). autocomplete (json1.data, {formatItem: function (item) {return item. shenFen ;}}). result (function (event, item) {$ ("# iPhone "). val (item. phone); $ ("# iName "). val (item. xingMing) ;}); // match the name $ ("# iName "). autocomplete (json1.data, {formatItem: function (item) {return item. xingMing ;}}). result (function (event, item) {$ ("# iPhone "). val (item. phone); $ ("# iCard "). val (item. shenFen );}) ;}); </Script> <body> <form id = "form1" runat = "server"> <input id = "aujson1" type = "hidden" value = "<% = aujson1 %> "/> <div> Tel: <input type = "text" id = "iPhone"/> id card: <input type = "text" id = "iCard"/> Name: <input type = "text" id = "iName"/> </div> </form> </body> public partial class test _ autoComplete: System. web. UI. page {public string aujson1 = string. empty; protected void Page_Load (object sender, EventArgs e) {If (! IsPostBack) {StringBuilder strb = new StringBuilder (); // initialize the json object, which is used to obtain the JSONHelp jsonhelp = new JSONHelp (); jsonhelp. successS = true; // As a json object. You can read jsonhelp from the database. addItem ("Phone", "123456789"); jsonhelp. addItem ("ShenFen", "412829198342342"); jsonhelp. addItem ("XingMing", "Xiong da"); jsonhelp. addItemOk (); jsonhelp. addItem ("Phone", "23456789"); jsonhelp. addItem ("ShenFen", "353453457031240"); jsonhelp. addItem ("XingMing", "Xiong 'er"); jsonhelp. addItemOk (); jsonhelp. addItem ("Phone", "345678912"); jsonhelp. addItem ("ShenFen", "423423423110638"); jsonhelp. addItem ("XingMing", "Zhang San"); jsonhelp. addItemOk (); jsonhelp. addItem ("Phone", "45678912"); jsonhelp. addItem ("ShenFen", "234254310120451"); jsonhelp. addItem ("XingMing", "Li Si"); jsonhelp. addItemOk (); jsonhelp. addItem ("Phone", "56789123"); jsonhelp. addItem ("ShenFen", "23423409121412"); jsonhelp. addItem ("XingMing", ""); jsonhelp. addItemOk (); jsonhelp. addItem ("Phone", "789012345"); jsonhelp. addItem ("ShenFen", "2234810402487"); jsonhelp. addItem ("XingMing", ""); jsonhelp. addItemOk (); //////////////////////////////////////// //// // aujson1 = jsonhelp. toString ();}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.