下拉框中如何添加小图标?

WhoAmI 2009-11-05 10:59:13
下拉框中添加图片啊? 拜求各位大侠~
...全文
1137 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Adechen 2009-11-05
  • 打赏
  • 举报
回复
写个类继承dropdownlist,重写Item对象
CopperBell 2009-11-05
  • 打赏
  • 举报
回复
必须重写Item对象
zhujiazhi 2009-11-05
  • 打赏
  • 举报
回复
selelct也可以加个图标的,不过当在select加入数据以后就看不到了
leon28 2009-11-05
  • 打赏
  • 举报
回复
用文本框+DIV自己写个控件
limii 2009-11-05
  • 打赏
  • 举报
回复
up
l245943272 2009-11-05
  • 打赏
  • 举报
回复
只能模仿
<html>
<head>
<title>模拟下拉列表框</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
body,td,div {font:12px 宋体}
label {height:19px;padding:3px 0px 0px 4px}
.link_box {text-align:left;cursor:default}
.link_head {width:100%;height:23;border:2px inset}
.link_text {background:#fff;padding-left:2px}
.link_arrow0 {font:14px marlett;text-align:center;width:22;height:100%;border:2px outset;background:buttonface}
.link_arrow1 {font:14px marlett;text-align:center;width:22;height:100%;border:1px solid buttonshadow;padding:2px 0px 0px 2px;background:buttonface}
.link_value {position:absolute;visibility:hidden;border:1px solid;overflow:auto;overflow-x:hidden;filter:alpha(opacity:0)}
.link_record0{width:100%;height:20;border-top:1px solid #eee;background:#fff;color:#000;padding-left:2px}
.link_record1{width:100%;height:20;border-top:1px solid #047;background:#058;color:#fe0;padding-left:2px}
</style>
<script>
var dropShow=false
var currentID
function dropdown(el){
if(dropShow){
dropFadeOut()
}else{
currentID=el
el.style.visibility="visible"
dropFadeIn()
}
}
function dropFadeIn(){//选单淡入的效果
if(currentID.filters.alpha.opacity<100){
currentID.filters.alpha.opacity+=20
fadeTimer=setTimeout("dropFadeIn()",50)
}else{
dropShow=true
clearTimeout(fadeTimer)
}
}
function dropFadeOut(){//选单淡出的效果
if(currentID.filters.alpha.opacity>0){
clearTimeout(fadeTimer)
currentID.filters.alpha.opacity-=20
fadeTimer=setTimeout("dropFadeOut()",50)
}else{
dropShow=false
currentID.style.visibility="hidden"
}
}
function dropdownHide(){
if(dropShow){
dropFadeOut()
dropShow=false
}
}
function hiLight(el){//高亮度显示指标位置
if(dropShow){
for(i=0;i<el.parentElement.childNodes.length;i++){
el.parentElement.childNodes(i).className="link_record0"
}
el.className="link_record1"
}
}
function CheckMe(el){//替换显示内容
el.parentElement.parentElement.childNodes(0).childNodes(0).childNodes(0).childNodes(0).childNodes(0).childNodes(0).innerHTML=el.innerHTML
}
document.onclick=dropdownHide
</script>
</head>

<body bgcolor="#0099FF" text="#000000" onload="document.form1.reset()">
<table align="center" width="100%" height="100%">
<tr><td align="center">
<table cellpadding=4 cellspacing=2 bgcolor=#a0a0a0 align="center"><tr>
<td bgcolor=#ddeeff width=160>范例1 (使用于表单)</td><td bgcolor=#ddeeff width=270>范例2 (使用于超连结)</td></tr>
<tr><td bgcolor=#e0e0e0 align=center>
<!--// 范例 1 开始 //-->
<table><tr><form name=form1 onsubmit="alert(city.value);return false"><td>
<div class=link_box style="width:100px" onselectStart="return false">
<div class=link_head onclick="dropdown(value1)">
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr>
<td><div id=text1 class=link_text><label>请选择?</label></div></td>
<td width=22 align=right><div class=link_arrow0 onmousedown="this.className='link_arrow1'" onmouseup="this.className='link_arrow0'" onmouseout="this.className='link_arrow0'">6</div></td>
</tr></table>
</div>
<div id=value1 class=link_value style="width:100%;height:100px">
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);document.form1.city.value=this.innerText"><label>北京市</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);document.form1.city.value=this.innerText"><label>上海市</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);document.form1.city.value=this.innerText"><label>河南省</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);document.form1.city.value=this.innerText"><label>深圳市</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);document.form1.city.value=this.innerText"><label>大连市</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);document.form1.city.value=this.innerText"><label>云南省</label></div>
</div>
</div>
</td><td>
<input type="hidden" name="city" value="您尚未选择">
<input type="submit" value="确定">
</td></form></tr></table>
<!--// 范例 1 结束 //-->
</td>
<td bgcolor=#e0e0e0 align=center>
<!--// 范例 2 开始 //-->
<div class=link_box style="width:250px" onselectStart="return false">
<div class=link_head onclick="dropdown(value2)">
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr>
<td><div class=link_text><img src="http://lucky.myrice.com/images/home.gif" align="absmiddle"><label>您想要浏览哪个网站?</label></div></td>
<td width=22 align=right><div class=link_arrow0 onmousedown="this.className='link_arrow1'" onmouseup="this.className='link_arrow0'" onmouseout="this.className='link_arrow0'">6</div></td>
</tr></table>
</div>
<div id=value2 class=link_value style="width:100%;height:82px">
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);window.open('http://lucky.myrice.com')"><img src="http://lucky.myrice.com/images/copyright.gif" align="absmiddle"><label>【孟宪会之精彩世界】一</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);window.open('http://lucky.myrice.com/')"><img src="http://lucky.myrice.com/images/copyright2.gif" align="absmiddle"><label>【孟宪会之精彩世界】二</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);window.open('http://lucky.myrice.com')"><img src="http://lucky.myrice.com/images/copyright.gif" align="absmiddle"><label>【孟宪会之精彩世界】一</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);window.open('http://lucky.myrice.com/')"><img src="http://lucky.myrice.com/images/copyright2.gif" align="absmiddle"><label>【孟宪会之精彩世界】二</label></div>
<div class=link_record0 onmouseover="hiLight(this)" onclick="CheckMe(this);window.open('http://www.sina.com.cn/')"><img src="http://lucky.myrice.com/images/oicq.gif" align="absmiddle"><label>新浪网</label></div>

</div>
</div>
<!--// 范例 2 结束 //-->
</td></tr>
</table>

</body>
</html>
l245943272 2009-11-05
  • 打赏
  • 举报
回复
DropDownList最终是转换为Html的Select,那么Select可以放图片吗?不可以!

如果要放图片,那么就不能使用DropDownList,而应该通过那些Javascript特技方式实现的下拉框,但已经不是select了。
Aderlee 2009-11-05
  • 打赏
  • 举报
回复
用其他控件模拟下拉框
yanzhiyong 2009-11-05
  • 打赏
  • 举报
回复
http://dotnet.aspx.cc/article/c81ad80e-fc14-4ff8-85f3-16cc68811bd5/read.aspx

这里有怎么模拟dropdownlist前后台代码都有。。。

62,253

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧