jquery simulation can input drop-down box

Source: Internet
Author: User

Page HTML<div id="Select" class="select" >                              <ul>                                <c:foreach Items="${moviecitylist}" var="cy"  Varstatus="St">                                    <li>                                        <a href="javascript:void (0)" onclick="Selectoption ($ (this))" >${cy.cityname}</a>                                        <input style="Display:none;" name="Citycode" id="Citycode${st.count}" value="${ Cy.vascityid} "/>                                    </li>                                </C:foreach>                              </ul>                            </div>
jquery Code<script type="Text/javascript">            //City drop-down box function             function getData(){//Get all City data                varData=New Array(); $(". Select a"). each ( function(i){data[i]=$ ( This). HTML (); });returnData } function judgelength(l){//Show drop-down box height based on results                if(l>5){                    $(". Select"). CSS ("Height","100px"); }Else{                    $(". Select"). CSS ("Height", l* -+"px"); }            } function selectoption(obj){//Selected$("#cityName"). Val (obj.html ()); $("#cityId"). Val (Obj.next ("Input"). Val ()); $(". Select"). Hide ();            Loadcinemalname (); } function onfocus(){//input Tag Get focus                varL=getdata (). length;if($(' #cityName '). val () = ="') {judgelength (L); $(". Select"). Show (); }Else{varobj=$ ("#cityName");                OnKeyUp (obj); }            } function onKeyUp(obj){//input KeyUp Events                varInput=obj.val () +"'; $(". Select Li"). Hide ();varheight=0;varData=getdata ();varL=getdata (). length;if(input!="'){//Input dynamically retrieves the presence of the entered city                     for(varI=0; i<data.length;i++) {varstr=data[i]+"";if(Str.indexof (Input)!=-1) {height++;                            Judgelength (height); $(". Select"). Show (); $(". Select Li:eq ("+i+")"). Show ();varcityid=$ (". Select Li:eq ("+i+") input"). Val (); $("#cityId"). Val (Cityid);                }} loadcinemalname (); }Else{judgelength (L); $(". Select Li"). Show (); }            } function onBlur(e){//Hide drop-down box when losing focusalert (e.target);//$ (". Select"). Hide ();}</script>

jquery simulation can input drop-down box

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.