Компания выбора раскрывающегося списка поддерживает функцию входного нечеткого запроса, а дизайн очень удобен для пользователя. Редактор ниже поделился с вами ключевым кодом. Вы можете добавить и изменить его соответствующим образом в соответствии с вашими потребностями. Если у вас есть какие -либо вопросы, дайте мне отзыв.
Ключевой код заключается в следующем:
<html> <Head> <meta http-equiv = 'content-type' content = 'text/html; charset = gb2312 '> <Title> Вводной раскрывающуюся поле </title> </head> <body> <script language = "javascript"> var j = 0; функция selectValue (obj) {var input = obj.parentNode.nextIbling; document.all.box2.value = obj.options [obj.selectedIndex] .Text; document.getElementById ("txtSection"). value = obj.options [obj.selectedIndex] .value; Alert (document.getElementById ("txtSection"). Значение); } функция 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 = "нет"; document.getElementbyId ("txtSection"). value = this.value; } msg.appendChild (selText); n ++; }}} else {document.all.msg.style.display = "none"; }} else {// нажмите клавишу вниз 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; }} // Нажмите клавишу вверх 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; }} // Нажмите клавишу ENTER if (event.keycode == 13) {tmpobj = document.getElementById ("selText"+j); document.all.box2.value = tmpobj.innerhtml; msg.style.display = "нет"; document.getElementbyId ("txtSection"). value = tmpobj.value; }}} функция selmatch (src) {var currsel = document.all.box2.value; for (var i = 0; i <src.length; i ++) {if (src (i) .text == currse) {src.options (i). Selected = true; }}} функция nomsg () {if (document.activeElement.id == "msg") вернуть false; else document.all.msg.style.display = 'none'; } </Script> <table border = 0 cellPadding = 1 cellspacing = 0> <Tr> <td> <font face = "arial" size = "2"> Раздел </font> </td> <td colspan = 3> <div Style = "Положение: относительно;"> <span Style = Margin-left: 230px; width: 18px; overflow; 22px; onchange = "selectValue (this)" onClick = "selmatch (this)" id = "selectOption" name = "selectOption"> <valie value = 'all' selected> all </option> <value = '0test1'> 0test1 = тестирование 1 <value = '0test1'> 0test2 = тестирование 1 <plaint value = '0test1'> testing1 = 0test1 = 0test1 = 0test1 = 0test. value = 'section'> section = раздел Описание xxxxx aaa </option> </select> </span> <name = "box2" id = "box2" onkeyup = "inputvalue (this)" onblur = "nomsg ()" onfocus = "this.select (); inputValue (this)" value = "0"> <divEd = "msg"; : 14px; белое пространство: nowrap; переполнение: скрыто;Выше приведено код реализации функции Fuzzy запроса Select Select Downllщика, представленной вам редактором. Я надеюсь, что это будет полезно для вас. Если у вас есть какие -либо вопросы, пожалуйста, оставьте мне сообщение, и редактор ответит вам вовремя. Большое спасибо за вашу поддержку сайту wulin.com!