This is the perfect solution for real-time monitoring of changes in input box values

Source: Internet
Author: User

I think: This function can solve the problem that onchange,onpropertychange,oninput is incompatible in the mainstream browser.

This feature is used to quickly blur find and add data

When the "T" letter is entered, a real-time list of 10 item names, spelling, model and other fields containing the T-letter data

Of course, you can enter Chinese character query, include more field fuzzy query, list more data and sort by some (out frequency, usage frequency) field.

When you re-enter "V", reload the data list and navigate to an item.

Click the plus sign

Added to the BOM list. and can be deleted

I prefer to write JS, but limited ability to write such a function. It also took a lot of effort.

The implementation function mainly uses the window.onload () function, SetInterval ("function name", MS) function, Jquery.ajax get the data. (to refer to the framework of jquery)

The SetInterval () function is equivalent to a clock in WinForm, and it takes too long to execute a function once, until the clearinterval () function executes, clearinterval () is not used, so it is not delved into.

Write the implementation process

1.window.onload () initializes the public variable. Execute SetInterval ("ShowData ()", 100), execute ShowData () function every 100 milliseconds

The 2.showdata () function determines whether there are keywords in the query text box, if not, skips, hides the data list, and then executes step 3rd.

3. Assign a keyword to a public variable, such as Currentkeyword, and save it as the next time you enter the function and the keyword does the same judgment, if the same is skipped, the difference is to perform the 4th step. (If this is not the case, the data list will always be assigned a value, affecting performance).

4.jquery.ajax gets the data, populates the data list, and displays the list of data.

5. End.

The code is not affixed, because the reference to the external CSS and scripts, can not be perfectly presented to you. If necessary, please leave a message or add: WANGXIHUI_GXFC

At the same time welcome the Big God small God pointing point.

Note: The title is to attract people to see.

This is the perfect solution for real-time monitoring of changes in input box values

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.