Web development, certainly encountered like Baidu, Google this search function bar, that intelligent form of automatic completion can do what, the following to announce:
1, including like Google, Baidu and other similar simple search
2, complex structure support, such as input product number, need to product number, product name, product price, product notes, etc. fill in the form of a location
The code is as follows (page address: https://github.com/xiexingen/Bootstrap-SmartForm/blob/master/demo/form3-ele-autocomplete.html):
Auto-complete
Note: JS files need to be introduced: Jquery-ui.js, jquery.fn.extend.js
Call the Smartsearch method by specifying an element after form generation is complete
Parameter description:
URL: Requested URL
Beforesearch: Optional, the method to be called before sending the request, the method has a parameter data containing the information to be sent, if you need to add or modify the parameters to be sent, modify the secondary parameters can be
Formatitem: Optional, if the return is not a simple array string, then the required custom action, used to format the interface display content, the example shows the product number + product Name
Callback: Optional, if the return is not a simple array string, a custom action is required to assign a value
Note: If the interface returns a simple array of strings, both Formatitem and callback can be omitted
This is what I run in my local test project:
For detailed usage, please refer to Demo
Previous chapter:BootStrap Smart Form series nine support for form picture uploading
Next chapter:BootStrap Smart Form Series 11 Cascade dropdown support
Series Home: BootStrap smart Form Series Home
BootStrap Smart Form Series 10 auto-complete component support