欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Select下拉框模糊查詢(xún)功能實(shí)現(xiàn)代碼

 更新時(shí)間:2016年07月22日 09:49:28   作者:morley_wang  
這篇文章主要介紹了Select下拉框模糊查詢(xún)功能實(shí)現(xiàn)代碼的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

select下拉列表框支持輸入模糊查詢(xún)功能,設(shè)計(jì)非常的人性化,下面小編給大家分享了關(guān)鍵代碼,大家根據(jù)自己的需求適當(dāng)?shù)奶砑有薷模腥魏螁?wèn)題歡迎給我反饋。

關(guān)鍵代碼如下所示:

<HTML> 
<HEAD> 
<META http-equiv='Content-Type' content='text/html; charset=gb2312'> 
<TITLE>可輸入的下拉框</TITLE> 
</HEAD> 
<BODY > 
<Script Language="Javascript"> 
var j = 0; 
function SelectValue(obj) 
{ 
var input = obj.parentNode.nextSibling; 
document.all.box2.value = obj.options[obj.selectedIndex].text; 
document.getElementById("txtSection").value=obj.options[obj.selectedIndex].value; 
alert(document.getElementById("txtSection").value); 
} 
function InputValue(obj) 
{ 
var n = 1; 
var tmpObj; 
var src = document.all.SelectOption; 
var msg = document.all.msg; 
if(event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 13){ 
if(obj.value!=""){ 
msg.style.display=""; 
msg.innerHTML=""; 
if(msg.hasChildNodes()) 
{ 
msg.childNodes[0].parentNode.removeChild(msg.childNodes[0]); 
} 
for (var i=0;i<src.length;i++){ 
var selValue = document.createElement("div"); 
var selText = document.createElement("div"); 
selText.value = src(i).value; 
selText.innerHTML = src(i).text; 
if (src(i).text.toLowerCase().indexOf(obj.value.toLowerCase())==0){ 
selText.setAttribute("id","selText"+n); 
selText.onmouseover=function (){ 
this.style.backgroundColor='#003399'; 
this.style.color ='#ffffff'; 
} 
selText.onmouseout=function (){ 
this.style.backgroundColor='#ffffff'; 
this.style.color ='#000000'; 
} 
selText.onclick=function (){ 
document.all.box2.value = this.innerHTML; 
msg.style.display="none"; 
document.getElementById("txtSection").value=this.value; 
} 
msg.appendChild(selText); 
n++; 
} 
} 
} 
else { 
document.all.msg.style.display="none"; 
} 
} 
else { 
//press down key 
if(event.keyCode==40){ 
j++; 
for (var i=0; i<src.length; i++) 
{ 
tmpObj = document.getElementById("selText"+i); 
if(tmpObj != null){ 
tmpObj.style.backgroundColor='#ffffff'; 
tmpObj.style.color ='#000000'; 
} 
} 
tmpObj = document.getElementById("selText"+j); 
if(tmpObj != null){ 
tmpObj.style.backgroundColor='#003399'; 
tmpObj.style.color ='#ffffff'; 
}else{ 
j = 0; 
} 
} 
//press up key 
if (event.keyCode==38){ 
j--; 
for (var i=0; i<src.length; i++) 
{ 
tmpObj = document.getElementById("selText"+i); 
if(tmpObj != null){ 
tmpObj.style.backgroundColor='#ffffff'; 
tmpObj.style.color ='#000000'; 
} 
} 
tmpObj = document.getElementById("selText"+j); 
if(tmpObj != null){ 
tmpObj.style.backgroundColor='#003399'; 
tmpObj.style.color ='#ffffff'; 
}else{ 
j = 2; 
} 
} 
//press enter key 
if (event.keyCode==13){ 
tmpObj = document.getElementById("selText"+j); 
document.all.box2.value = tmpObj.innerHTML; 
msg.style.display="none"; 
document.getElementById("txtSection").value=tmpObj.value; 
} 
} 
} 
function SelMatch(src) 
{ 
var currSel = document.all.box2.value; 
for (var i=0;i<src.length;i++){ 
if (src(i).text==currSel) 
{ 
src.options(i).selected = true; 
} 
} 
} 
function NoMsg() 
{ 
if(document.activeElement.id=="msg") 
return false; 
else 
document.all.msg.style.display='none'; 
} 
</Script> 
<TABLE border=0 cellPadding=1 cellSpacing=0 width="100%"> 
<TR> 
<TD width="24%"><font face="Arial" size="2">Section</font></TD> 
<TD COLSPAN=3 width="76%"> 
<div style="position:relative;"> 
<span style="margin-left:230px;width:18px;overflow:hidden;"> 
<select style="HEIGHT: 22px; WIDTH: 250px; margin-left:-232px;" onchange="SelectValue(this)" onclick="SelMatch(this)" id="SelectOption" name="SelectOption" > 
<OPTION value='ALL' Selected>ALL</OPTION> 
<OPTION value='0TEST1'>0TEST1 = Testing 1 
<OPTION value='0TEST1'>0TEST2 = Testing 1 
<OPTION value='0TEST1'>0TEST3 = Testing 1 
<OPTION value='SECTION'>SECTION = Section Description XXXXX AAA 
</OPTION> 
</select></span> 
<input name="box2" id="box2" style="width:230px;position:absolute;left:0px;" onkeyup="InputValue(this)" onblur="NoMsg()" onfocus="this.select();InputValue(this)" value="0" > 
<div id="msg" style="border:1px solid green; font-size :14PX;white-space:nowrap;overflow:hidden; 
width:230px;position:absolute;left:0px;top:20px;display:none"></div> 
</div> 
<Input Type="Hidden" Name="txtSection" id="txtSection"> 
</TD> 
</TR> 
</TABLE> 
<p> 
</BODY></HTML> 

以上所述是小編給大家介紹的Select下拉框模糊查詢(xún)功能實(shí)現(xiàn)代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • jquery中click等事件綁定及移除的幾種方法小結(jié)

    jquery中click等事件綁定及移除的幾種方法小結(jié)

    這篇文章主要介紹了jquery中綁定事件與解綁事件是常用到的寫(xiě)法,這里總結(jié)了幾種常見(jiàn)的綁定事件與解綁事件的方法,需要的朋友可以參考下
    2023-05-05
  • JS設(shè)計(jì)模式之狀態(tài)模式的用法使用方法

    JS設(shè)計(jì)模式之狀態(tài)模式的用法使用方法

    JavaScript狀態(tài)模式是一種行為型設(shè)計(jì)模式,核心是對(duì)象在其內(nèi)部狀態(tài)改變時(shí)改變其行為,狀態(tài)模式將對(duì)象的行為封裝到不同的狀態(tài)類(lèi)中,使得對(duì)象在不同狀態(tài)下可以選擇不同的行為,本文給大家詳細(xì)的介紹一下?tīng)顟B(tài)設(shè)計(jì)模式在Js中的使用,需要的朋友可以參考下
    2023-08-08
  • 谷歌showModalDialog()方法不兼容出現(xiàn)對(duì)話窗口的解決辦法

    谷歌showModalDialog()方法不兼容出現(xiàn)對(duì)話窗口的解決辦法

    這篇文章給大家介紹了谷歌showModalDialog()方法不兼容出現(xiàn)對(duì)話窗口的解決辦法,解決辦法非常好,感興趣的朋友可以參考下
    2016-02-02
  • JavaScript實(shí)現(xiàn)Promise流程詳解

    JavaScript實(shí)現(xiàn)Promise流程詳解

    首先呢,Promise是異步中比較重要的知識(shí)點(diǎn),學(xué)習(xí)的最好方法就是掌握它的基本原理。所以這一篇主要說(shuō)一下如何用JS來(lái)實(shí)現(xiàn)一個(gè)自己的promise
    2022-09-09
  • JavaScript 拖拽實(shí)例代碼

    JavaScript 拖拽實(shí)例代碼

    這篇文章主要介紹了JavaScript 拖拽實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下
    2016-09-09
  • 利用uni-app生成微信小程序的踩坑記錄

    利用uni-app生成微信小程序的踩坑記錄

    uni-app是一個(gè)使用 Vue.js 開(kāi)發(fā)所有前端應(yīng)用的框架,開(kāi)發(fā)者編寫(xiě)一套代碼,可發(fā)布到iOS、Android、H5、以及各種小程序(微信/支付寶/百度/頭條/QQ/釘釘)等多個(gè)平臺(tái),這篇文章主要給大家介紹了關(guān)于利用uni-app生成微信小程序的踩坑記錄,需要的朋友可以參考下
    2022-04-04
  • 深入理解JavaScript系列(8) S.O.L.I.D五大原則之里氏替換原則LSP

    深入理解JavaScript系列(8) S.O.L.I.D五大原則之里氏替換原則LSP

    本章我們要講解的是S.O.L.I.D五大原則JavaScript語(yǔ)言實(shí)現(xiàn)的第3篇,里氏替換原則LSP(The Liskov Substitution Principle )。
    2012-01-01
  • 關(guān)閉瀏覽器窗口彈出提示框并且可以控制其失效

    關(guān)閉瀏覽器窗口彈出提示框并且可以控制其失效

    這篇文章主要介紹了關(guān)閉瀏覽器窗口時(shí)彈出提示框,并且可以通過(guò)函數(shù)控制其失效,需要的朋友可以參考下
    2014-04-04
  • 微信小程序如何再次獲取用戶授權(quán)的方法

    微信小程序如何再次獲取用戶授權(quán)的方法

    這篇文章主要介紹了微信小程序如何再次獲取用戶授權(quán)的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • javascript封裝 Cookie 應(yīng)用接口

    javascript封裝 Cookie 應(yīng)用接口

    本文通過(guò)幾個(gè)簡(jiǎn)單的示例向大家展示了javascript封裝cookie的注意事項(xiàng)及操作方法,非常的簡(jiǎn)單實(shí)用,最后附上一則具體實(shí)例,有需要的小火把可以參考下。
    2015-08-08

最新評(píng)論