首页技术html中下拉列表代码 下拉菜单的代码

html中下拉列表代码 下拉菜单的代码

编程之家2026-05-31628次浏览

大家好,今天来为大家分享html中下拉列表代码的一些知识点,和下拉菜单的代码的问题解析,大家要是都明白,那么可以忽略,如果不太清楚的话可以看看本篇文章,相信很大概率可以解决您的问题,接下来我们就一起来看看吧!

html中下拉列表代码 下拉菜单的代码

HTML 下拉 列表 框的问题

是可以实现的,只是比较麻烦,参考代码如下:

<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

html中下拉列表代码 下拉菜单的代码

<style>

/* CSS Document*/

/* for input_dropMenu*/

body{

line-height:10px;

SCROLLBAR-FACE-COLOR:#eeeedd;

SCROLLBAR-HIGHLIGHT-COLOR:#eeeedd;

SCROLLBAR-SHADOW-COLOR:#666677;

SCROLLBAR-3DLIGHT-COLOR:#666677;

SCROLLBAR-ARROW-COLOR:#666677;

SCROLLBAR-TRACK-COLOR:#efefef;

SCROLLBAR-DARKSHADOW-COLOR:#eeeedd;

}

div{

font-size:9pt;

}

.dropMenu{

overflow:auto;

overflow-x:visible;

height:100%;

border-top:1px solid#aaaabb;

border-left:1px solid#aaaabb;

border-right:1px solid#666677;

border-bottom:2px solid#666677;

background-color:#fdfdfd;

FILTER:progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=white,endColorStr=#eeeedd);

white-space:nowrap;

}

.dropMenu div{

cursor:Default;

color:#666677;

padding:1px 2px 1px 2px;

padding-top:2px;

script1:expression(

onmouseover=function(){

this.style.background="#0A246A"

this.style.fontWeight="normal"

this.style.color="white"

this.style.paddingLeft="3px"

},

onmouseout=function(){

this.style.background="none"

this.style.fontWeight="normal"

this.style.color="#666677"

this.style.paddingLeft="2px"

},

onclick=function(){

choose_dropMenu(this.parentNode.style.parent1,this)

}

);

}

</style>

</head>

<script language="JavaScript">

// JavaScript Document

/*

=== for input_dropMenu===

=== gotCode 2004-9-21===

*/

function drawShadowDiv(){

sDiv='<div id="shadowDiv"'+

'style="'+

'position:absolute;'+

'left:0px;top:0px;'+

'z-index:1;'+

'background-color:#2C6C85;'+

'layer-background-color:#2C6C85;'+

'display:none;'+

'FILTER:progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=10,finishOpacity=20,startX=0,finishX=0,startY=0,finishY=100);'+

'border:1px solid skyblue;'+

'"></div>'

document.write(sDiv)

}

drawShadowDiv()

function giveItShaow( which, sDiv,type){

if( type=="show"){

sDiv.style.zIndex= which.style.zIndex

sDiv.style.left= which.offsetLeft+ which.parentNode.offsetLeft+ 2;

sDiv.style.top= which.offsetTop+ which.parentNode.offsetTop+ 3;

sDiv.style.width= which.offsetWidth;

sDiv.style.height= which.offsetHeight;

sDiv.style.display="";

}else{

sDiv.style.display="none"

sDiv.style.zIndex= 1

}

}

//===显示下拉框===

/*

current_dropMenu=页面当前下拉框的ID

close_dropMenu=是否可以关闭下拉框

dropMenuGo= setTimeout的变量

*/

var current_dropMenu= null

var close_dropMenu= true

var dropMenuGo= null

function show_dropMenu( which){

current_dropMenu= which

if( dropMenuGo!= null){

clearTimeout(dropMenuGo)

}

//info.innerText= which.style.script1

eval("outSide_"+which.id).style.display=""

which.style.display=""

which.scrollTop= 0

marginTop= parseInt(which.style.marginTop)

if( marginTop<-3){

which.style.marginTop= marginTop+ Math.round(( 0- marginTop)/3)

}else if( marginTop>=-3&& marginTop< 0){

which.style.marginTop= marginTop+ 1

}

if( marginTop>= 0){

clearTimeout(dropMenuGo)

giveItShaow(which,shadowDiv,'show')

return

}

dropMenuGo= setTimeout("show_dropMenu("+which.id+")",10)//

}

//===隐藏下拉框===

function hide_dropMenu(){

if( current_dropMenu!= null){

if( close_dropMenu){

clearTimeout(dropMenuGo)

current_dropMenu.style.display="none"

eval("outSide_"+current_dropMenu.id).style.display="none"

current_dropMenu.style.marginTop= current_dropMenu.parentNode.offsetHeight*(-1)

giveItShaow(current_dropMenu,shadowDiv,'hide')

}

}

}

//===选择下拉框的值===

function choose_dropMenu( which, self){

close_dropMenu= true

hide_dropMenu()

//eval(which).document.body.innerText= self.innerText.substr(0,self.innerText.length-1)

eval(which).value= self.innerText

}

//===除前后空格===

function trim(str){

if( str.substr(0,1)==""){

str= str.substr(1)

}

if( str.substr(str.length-1,1)==""){

str= str.substr(0,str.length-2)

}

return str

}

function replaceFilters( str){

//str= str.replace(//g,"")

str= trim(str)

str= str.replace(/=/g,':')

str= str.replace(/:/g,':"')

str= str.replace(//g,'')

str= str.replace(/:"\/\//g,'://')

str= str.replace(/javascript:"/g,'javascript:')

str= str.replace(/,/g,'",')

str= str+'"'

str= str.replace(/""/g,'"')

str="{"+ str+"}"

return str

}

/*

type=变量名称

defaultVariables=默认的值(不能为空)

*/

function setFilters( type, defaultVariables){

if( filters[type]== undefined){

if( defaultVariables== undefined){

defaultVariables=""

}

eval( type+"=defaultVariables")

}else{

eval( type+"=filters[type]")

}

}

var getStr, cTmpStr

function Separate_Str(){

getStr=""

for( i= 0; i< cTmpStr.length; i++){

if( cTmpStr.substr(i,1)==""){

cTmpStr= cTmpStr.substr(getStr.length+1)

return getStr

}

getStr= getStr+ cTmpStr.substr(i,1)

}return getStr

}

//===drawDropMenu===

/*

iAutoID=自动编号

id=输入框的值

*/

var iAutoID= 0;

function SS_drawDropMenu( filter){

iAutoID++

if( filter== undefined){

filters={}

}else{

eval("filters="+ replaceFilters( filter))

}

setFilters("id","inputFrame"+iAutoID)

setFilters("form","")

setFilters("maxlength","")

setFilters("cItem","没有选项")

setFilters("value","")

setFilters("startColor","white")

setFilters("endColor","#eeeedd")

setFilters("onfocus","'javascript:;'")

setFilters("onblur","'javascript:;'")

setFilters("onmouseover","'javascript:;'")

setFilters("onmouseout","'javascript:;'")

setFilters("onmouseup","'javascript:;'")

setFilters("onmousedown","'javascript:;'")

setFilters("onkeyup","'javascript:;'")

setFilters("onkeydown","'javascript:;'")

setFilters("onchange","'javascript:;'")

if( form!=""){

parent1= form+"."+id

}else{

parent1= id

}

//---建立下拉框选项的html语句---

var itemCount//-下拉框选项的循环次数

var itemHtml=""//-html语句

var dropMenuHeight=""

var inputSize= 0//-下拉框的高度

itemCount= cItem.split('').length

cTmpStr= cItem

for( var i= 0; i< itemCount; i++){

menuValue= Separate_Str()

itemHtml= itemHtml+'<div>'+menuValue+'</div>\n'

if( menuValue.length> inputSize){

inputSize= menuValue.length

}

}

if( itemCount< 5){

dropMenuHeight=(17* itemCount+3)

}else{

dropMenuHeight= 88

}

setFilters("size", inputSize*2)

//---end---

oHtml='<div id="input_dropMenu'+id+'" style="display:inline;height:21px;">\n'+

'<table border="0" cellspacing="0" cellpadding="0">\n'+

'<tr>\n'+

'<td style="font-size:9pt;border:1px solid black;border-right:0px;">\n'+

'<input name="'+id+'" type="text" value="'+value+'" size="'+size+'" maxlength="'+maxlength+'" style="font-size:9pt;border:0px solid black;"'+

' onfocus='+onfocus+

' onblur='+onblur+

' onmouseover='+onmouseover+

' onmouseout='+onmouseout+

' onmouseup='+onmouseup+

' onmousedown='+onmousedown+

' onkeyup='+onkeyup+

' onkeydown='+onkeydown+

' onchange='+onchange+

'>'+

'</td>\n'+

'<td width="16px" style="font-size:9pt;border:1px solid black;border-left:0px;border-right:0px;">\n'+

'<div style="'+

'font-family:webdings;'+

'overflow:hidden;'+

'height:18;'+

'margin-left:-1px;'+

'border:2px solid outset;'+

'FILTER:progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr='+startColor+',endColorStr='+endColor+');'+

'"'+

' onmousedown="this.style.border=\'2px inset\'"'+

' onmouseup="this.style.border=\'2px outset\'"'+

' onmouseover="this.style.border=\'2px outset\'"'+

' onmouseout="this.style.border=\'2px outset\'"'+

'>\n'+

'<div style="'+

'font-size:9pt;'+

'margin-top:-3px;'+

'margin-left:1px;'+

'cursor:hand;'+

'color:#444444'+

'"'+

' onClick="show_dropMenu(dropMenu'+id+')"'+

' onmousedown="this.style.marginLeft=\'2px\';"'+

' onmouseup="this.style.marginLeft=\'1px\'"'+

' onselectstart="return false"'+

'>6</div>\n'+

'</div>\n'+

'</td>\n'+

'</tr>\n'+

'<tr>\n'+

'<td colspan="2">\n'+

'<div id="outSide_dropMenu'+id+'"'+

' class="outSideDropMenu"'+

' onselectstart="return false"'+

'style="'+

'display:none;'+

'position:absolute;'+

'z-index:21;'+

'margin-top:-1px;'+

'height:'+dropMenuHeight+'px;'+

'width:100%;'+

'overflow:hidden;'+

'overflow-x:visible;'+

'border:0px solid black;'+

'">\n'+

'<div id="dropMenu'+id+'" class="dropMenu" style="margin-top:expression(this.parentNode.offsetHeight*(-1));parent1:'+parent1+'" onMouseover="close_dropMenu=false;" onMouseout="close_dropMenu=true;">\n'+

itemHtml+

'</div>\n'+

'</div>\n'+

'</td>\n'+

'</tr>\n'+

'</table>\n'+

'</div>\n'

document.write(oHtml)

}

</script>

<body onMousedown="hide_dropMenu();">

<form name="form1" method="post" action="">

姓名:

<input name="cName" type="text" id="cName" size="10">

<br>

年龄:

<input name="iAge" type="text" id="iAge" size="10">

<br>

职位:<script>SS_drawDropMenu('id=kkk,form=form1,cItem=科员科长所长局长')</script><script>SS_drawDropMenu('id=kkk2,form=form1,cItem=科员科长所长局长')</script>

<input name="dd" type="button" value="提交" onclick="alert(form1.kkk.value)">

</form>

<p></p></body>

</html>

html+css下拉菜单怎么制作

使用HTML和CSS制作下拉菜单的方法如下:

1、编写带有div导航的html代码:

2、使用class=“nav”属性的‘div’标签作为菜单的容器。在截图中,在图示的HTML代码中,一个简单的无序列表(ul)来表示主菜单项。

3、在主菜单区域中添加链接。在本步骤中,在无序列表(ul)每一项上添加链接。

4、在“关于我们(About Us)”下方LI标签内添加一个无序列表,它代表其子菜单的链接。

5、制作导航css:

html页面中下拉列表怎么控制宽度

1、直接设置select标签的宽度就可以了。具体的操作步骤首先需要新建一个html文件,在文件中创建2个select下拉列表:

2、然后在上方的head标签中设置style样式表,首先设置第一个select标签的宽度,这里设置select1的样式标签的宽度为300px,为一个精确值,并设置一下高度和背景颜色,方便接下来查看效果:

3、然后设置select2的宽度,这里使用百分比设置宽度,百分比代表的是铺满整个屏幕所占的比例,这里设置为50%:

4、最后来到浏览器,即可看到两个不同宽度的select下拉列表了。以上就是html页面中下拉列表控制宽度的方法:

END,本文到此结束,如果可以帮助到大家,还望关注本站哦!

vlookup多项匹配 vlookup简单使用方法javaplayer下载手机版?JayPlayer手机版下载