Effect
First, all values are traversed and placed in the div and hidden
<DivID= "All_company_name_list"Hidden> <C:foreachvar= "Item"Items= "${companynamelist}"> <Liclass= "Company"company_id= "${item.id}"company_name= "${item.companyname}"onclick= "Completeauto (this);">${item.companyname}</Li> </C:foreach> </Div>
Here is the input box and put a hidden display ul
<Divclass= "Nr4-info nr4-list"> <P>Affiliated Enterprises:</P><inputtype= "text"ID= "Text_input"name= "CompanyName"class= "Nr4_inp2 ni"value= "${companyinfoentity.companyname}" onkeyup= "Auto ();" /><Divclass= "Show-wrap"> <ulID= "Show-company-list"Hidden> </ul> </Div> <inputtype= "hidden"ID= "CompanyID"value= "${companyinfoentity.id}"> <I>(Please select an existing enterprise)</I></Div>
Ss
$(function () { $("#form"). Click (function(){ //$ ("#companyId"). Val ("");$ ("#show-company-list"). Hide (); });});functionAuto () {$ (". Show-wrap"). Show (); //When the input box is focused and a value is entered, the drop-down box is displayed $ ("#show-company-list"). html (' <li class= ' Company "company_id="-1 "company_name=" "onclick=" Completeauto (this); " ></li> '); //The first line shows a null value varstr = $.trim ($ ("#text_input"). Val ()); //Get the value of the input box
$.each ($ ("#all_company_name_list. Company"),function(Index, value) {//traversal if(str = = "" | | $ (value). attr ("Company_Name"). IndexOf (str) >-1)//Because the text box is not required, you can have a null value of $ ($ ( This). Clone ()). AppendTo ($ ("#show-company-list")); //Here the last clone to the drop-down box we want to display}); $("#show-company-list"). Show (); ///show It last }functionCompleteauto (obj) {$ ("#text_input"). Val ($ (obj). attr ("Company_Name")); //Click the value in the drop-down box to assign a value to the input text box $ ("#companyId"). Val ($ (obj). attr ("company_id")); //Click the value in the drop-down box to assign a value to the ID in the hidden field $ ("#show-company-list"). Hide (); //After the assignment is finished, put the drop-down box back up }
$ ("#all_company_name_list. Company") This is to get the hidden value (all the values that were queried early in the DIV)
$ (value). attr ("Company_Name"). IndexOf (str) >-1 Find value containing str and assign to Company_Name
Lenovo (query out all, and then enter the de-contrast whether it contains)