Lenovo (query out all, and then enter the de-contrast whether it contains)

Source: Internet
Author: User
Tags lenovo

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)

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.