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