dropdownlist问题?请教高手!! 是不是有个tooltip之类的东东,记不大清 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 tooltip对dropdownlist的选项没有用的。关注 dropdownlist.Attributes["onmouseover"]="javascript函数显示“; string aa="你要显示的注释";DropDownList1.Attributes .Add("onchange","Javascript:show("+aa+");");客户端<script>function show(){ 。。}</script> 一般对有类似要求的方法有:方法1:工具提示(即楼上说的tooltip)方法2:onmouseover事件的使用(用javascript or vb) 我是从asp.net 学起的,不会角本语言,另外我是用C#编写,请详细赐教,不禁感激 tooltip:不管你选定的是什么,提示都只有一种你可以考虑有helimin19(冷风)和My286(会飞的鱼)的方法 跟你说得很象!拿去用吧~~~!------------------------------------------------------<Html><Head><SCRIPT LANGUAGE="JavaScript"><!--//定义 select 原值var oldValue,oldText;//select下拉框的onkeydown事件,修改下拉框的值function catch_keydown(sel){ switch(event.keyCode) { case 13: //回车键 event.returnValue = false; break; case 27: //Esc键 sel.options[sel.selectedIndex].text = oldText; sel.options[sel.selectedIndex].value = oldValue; event.returnValue = false; break; case 8: //空格健 var s = sel.options[sel.selectedIndex].text; s = s.substr(0,s.length-1); if (sel.options[sel.selectedIndex].value==sel.options[sel.selectedIndex].text) { sel.options[sel.selectedIndex].value=s; sel.options[sel.selectedIndex].text=s; } event.returnValue = false; break; } if (!event.returnValue && sel.onchange) sel.onchange(sel)}//select下拉框的onkeypress事件,修改下拉框的值function catch_press(sel){if(sel.selectedIndex>=0){ var s = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode); if (sel.options[sel.selectedIndex].value==sel.options[sel.selectedIndex].text) { sel.options[sel.selectedIndex].value=s; sel.options[sel.selectedIndex].text=s; } event.returnValue = false; if (!event.returnValue && sel.onchange) sel.onchange(sel) }}//select下拉框的onfocus事件,保存下拉框原来的值function catch_focus(sel) { oldText = sel.options[sel.selectedIndex].value; oldValue = sel.options[sel.selectedIndex].value;}//恢复select下拉列表当前选中的值function LoadSelect(obj,value){ for (var i=0; i< obj.options.length; i++) if (obj.options[i].value == value) { obj.selectedIndex = i; break; }}//select 选择框鼠标上移时提示选择的内容function selMouseOver(obj){ with (document.all.div_hint) { innerText = obj.options[obj.selectedIndex].text; if (innerText.length > 0) { innerText = " " + innerText + " "; style.display = "block"; style.left = event.clientX + 16; style.top = event.clientY; } }}//select 选择框鼠标移开时消失function selMouseOut(obj){ with (document.all.div_hint) { style.display = "none" }}//--></SCRIPT></Head><Body><!--调用--><select style='width:130px;z-index:-1' name='tmpSel' onmouseover=selMouseOver(this) onmouseout=selMouseOut(this) onkeydown=catch_keydown(this) onkeypress=catch_press(this) onfocus=catch_focus(this)> <option value='我是老大!'>我是老大</option> <option value='我是老二!!!'>我是老二</option> <option value='我是老二!!!'>我是老三</option></select><!--提示块--><div id=div_hint style="font-size:12px;color:red;display:none;position:absolute; z-index:2; top:200;background-color: #F7F7F7; layer-background-color: #0099FF; border: 1px #9c9c9c solid;filter:Alpha(style=0,opacity=80,finishOpacity=100);"></div></Body></Html> GridView 根据内容 动态设置背景色 每次打开IE8浏览器都会出现欢迎使用对话框 Cookie 获取值时 类型转换、 防止同一用户同时登录(asp.net) HTML控件转义的问题。SOS!谢谢!! 页面上的Table消失了,怎么办? 如何在page_Load时设置该页一个用户控件中使用DataBind(比如下拉框)的值 用户控件里调用Form总是报jscript错误,求助 邮件发送问题?“SendUsing”配置值无效 一个将B网页的值送回A网页的问题。 TREEVIEW编译错误 datagrid 数据项按月小计、年总计
关注
DropDownList1.Attributes .Add("onchange","Javascript:show("+aa+");");客户端
<script>
function show()
{
。。
}
</script>
方法1:工具提示(即楼上说的tooltip)
方法2:onmouseover事件的使用(用javascript or vb)
拿去用吧~~~!------------------------------------------------------
<Html>
<Head>
<SCRIPT LANGUAGE="JavaScript">
<!--
//定义 select 原值
var oldValue,oldText;
//select下拉框的onkeydown事件,修改下拉框的值
function catch_keydown(sel)
{
switch(event.keyCode)
{
case 13: //回车键
event.returnValue = false;
break;
case 27: //Esc键
sel.options[sel.selectedIndex].text = oldText;
sel.options[sel.selectedIndex].value = oldValue;
event.returnValue = false;
break;
case 8: //空格健
var s = sel.options[sel.selectedIndex].text;
s = s.substr(0,s.length-1);
if (sel.options[sel.selectedIndex].value==sel.options[sel.selectedIndex].text)
{
sel.options[sel.selectedIndex].value=s;
sel.options[sel.selectedIndex].text=s;
}
event.returnValue = false;
break;
}
if (!event.returnValue && sel.onchange)
sel.onchange(sel)
}//select下拉框的onkeypress事件,修改下拉框的值
function catch_press(sel){
if(sel.selectedIndex>=0){
var s = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
if (sel.options[sel.selectedIndex].value==sel.options[sel.selectedIndex].text)
{
sel.options[sel.selectedIndex].value=s;
sel.options[sel.selectedIndex].text=s;
}
event.returnValue = false;
if (!event.returnValue && sel.onchange)
sel.onchange(sel)
}
}//select下拉框的onfocus事件,保存下拉框原来的值
function catch_focus(sel) {
oldText = sel.options[sel.selectedIndex].value;
oldValue = sel.options[sel.selectedIndex].value;
}//恢复select下拉列表当前选中的值
function LoadSelect(obj,value)
{
for (var i=0; i< obj.options.length; i++)
if (obj.options[i].value == value)
{
obj.selectedIndex = i;
break;
}
}//select 选择框鼠标上移时提示选择的内容
function selMouseOver(obj)
{
with (document.all.div_hint)
{
innerText = obj.options[obj.selectedIndex].text;
if (innerText.length > 0)
{
innerText = " " + innerText + " ";
style.display = "block";
style.left = event.clientX + 16;
style.top = event.clientY;
}
}
}//select 选择框鼠标移开时消失
function selMouseOut(obj)
{
with (document.all.div_hint)
{
style.display = "none"
}
}
//-->
</SCRIPT>
</Head>
<Body>
<!--调用-->
<select style='width:130px;z-index:-1' name='tmpSel' onmouseover=selMouseOver(this) onmouseout=selMouseOut(this) onkeydown=catch_keydown(this) onkeypress=catch_press(this) onfocus=catch_focus(this)>
<option value='我是老大!'>我是老大</option>
<option value='我是老二!!!'>我是老二</option>
<option value='我是老二!!!'>我是老三</option>
</select><!--提示块-->
<div id=div_hint style="font-size:12px;color:red;display:none;position:absolute; z-index:2; top:200;background-color: #F7F7F7; layer-background-color: #0099FF; border: 1px #9c9c9c solid;filter:Alpha(style=0,opacity=80,finishOpacity=100);"></div>
</Body>
</Html>