SoFunction
Updated on 2025-03-01

js method to implement the Select drop-down box with input function

This article describes the method of implementing the Select drop-down box with input function in js. Share it for your reference. The specific implementation method is as follows:

Implementation method one

Copy the codeThe code is as follows:
<HTML>
<HEAD>
<META http-equiv='Content-Type' content='text/html; charset=gb2312'>
<TITLE>js implements inputable drop-down box</TITLE>
</HEAD>
<BODY>
<div style="position:relative;">
<span style="margin-left:100px;width:18px;overflow:hidden;">
<select style="width:118px;margin-left:-100px" onchange="=">
<option value="Germany">Germany</option>
<option value="Norway">Norway</option>
<option value="Switzerland"> Switzerland</option>
</select></span><input name="box" style="width:100px;position:absolute;left:0px;">
</div>
</BODY>
</HTML>

Implementation method two

Copy the codeThe code is as follows:
<select onkeydown="(this,event)" onkeypress="(this,event)">
<option value=""></option>
<option value="aaa">aaa</option>
<option value="bbb">bbb</option>
<option value="ccc">ccc</option>
</select>
<input type="button" value="get the selection value" onclick="test();"/>
<script>
var Select = {
del : function(obj,e){
if((||||) == 8){
var opt = [0];
= = (0, >0?-1:0);
}
},
write : function(obj,e){
if((||||) == 8)return ;
var opt = [0];
= "selected";
= += (||||);
}
}
function test(){
alert(("select").value);
}
</script><br />

I hope this article will be helpful to everyone's JavaScript programming.