HTML可输入编辑的下拉选择框怎么做
展开全部
代码
<html>
<body>
<FORM id=FORM1 name=FORM1 method=post language=JavaScript>
<INPUT class="Input" id=TxtBoxNo name=TxtBoxNo onkeyup="return Item_onkeyup(this,FORM1.BoxNo_input)"><span class="Span" id=SpanBoxNo name="SpanBoxNo">
<SELECT class="Select" id=BoxNo_input name=BoxNo_input onBlur="return Item_onBlur(this,FORM1.TxtBoxNo)" onMouseOver="return Item_onMouseOver(this)" onchange="return Input_onchange(this)">
<OPTION value="1" selected>1</OPTION>
<OPTION value="2">2</OPTION>
<OPTION value="3">3</OPTION>
<OPTION value="4">4</OPTION>
<OPTION value="5">5</OPTION>
<OPTION value="6">6</OPTION>
<OPTION value="7">7</OPTION>
<OPTION value="8">8</OPTION>
<OPTION value="9">9</OPTION>
<OPTION value="10">10</OPTION>
</SELECT>
</span>
<script language="JavaScript">
function Item_onkeyup(Object,ObjSelect){
var src = Object.value;
/*
if( ObjSelect.id == "BoxNo_input" ){
var LoopLen=
6-src.length; for(vari=0,j=0;i<LoopLen;i++ ){
src = j.toString() + src.toString();
}
}
*/
var hoststr = ObjSelect.value;
var pos=1;
//var ver = Number(ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion())
//if (ver >= 5.5){
for(var i=0; i< ObjSelect.length ;i++){
hoststr = Rtrim(ObjSelect.options[i].value.toString());
if( Rtrim(src) == Rtrim(hoststr) ){
pos = 0;
}
//alert( pos );
if( pos == 0 ){
ObjSelect.options[i].selected = true;
if( ObjSelect.options[ObjSelect.length-1].text == "クテヨオイサコマキィ" ) {
ObjSelect.options[ObjSelect.length-1] = null;
}
return true;
}//if()
else{
ObjSelect.value = "";
}
}//for()
if( ObjSelect.value == "" ){
if( ObjSelect.options[ObjSelect.length-1].value != "" ){
ObjSelect.options[ObjSelect.length] = new Option("クテヨオイサコマキィ","",false,true);
}//if()
}//if()
//}//if()
}//function()
function Item_onBlur(Object,TxtObject){
Object.style.width=22;
Object.style.left=0;
}
function Item_onMouseOver(Object){
Object.style.width=135;
Object.style.left=-113;
}
function Input_onchange(ObjSelect) {
if( ObjSelect.id == "BoxNo_input" ) {
FORM1.TxtBoxNo.value = ObjSelect.value;
}
else if( ObjSelect.id == "UserID_input" ) {
FORM1.TxtUserID.value = Rtrim(ObjSelect.value);
}
if( ObjSelect.options[ObjSelect.length-1].text == "クテヨオイサコマキィ" ) {
ObjSelect.options[ObjSelect.length-1] = null;
}
}
function Rtrim(Value){
var src=Value;
var des=" ";
var pos = src.search(des);
return src.substring( 0, pos )?src.substring( 0, pos ):Value;
}
</script>
<STYLE type=text/css>
.Input
{
FONT-WEIGHT:700;
COLOR:WHITE;
BACKGROUND-COLOR:ORANGE;
HEIGHT:20PX;
WIDTH:113PX;
}
.Span
{
POSITION:absolute;
}
.Select
{
FONT-WEIGHT:700;
LEFT:0PX;
POSITION:absolute;
TOP:0px;
WIDTH:22px;
COLOR:WHITE;
BORDER-RIGHT-LEFT:0px;
BACKGROUND-COLOR:ORANGE;
}
</STYLE>
</FORM>
</body>
</html>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询