日期:2014-05-18  浏览次数:20821 次

!!!急,关于下拉框的选项值的显示详细信息问题!!!
我用的是一个动态的下拉框,他的值的长度可以在200个字节内,但是在下拉框中不可能全部显示出来,只能显示前20个字符,当我移到这个选项时应该显示出他的详细信息。
原以为用title属性可以,后来发现不行,有哪位大侠能帮忙解决,在下感激涕零!!!!

------解决方案--------------------
关注楼主的问题.
------解决方案--------------------
up..
------解决方案--------------------
做不到的,我也想过这样做,
------解决方案--------------------
可以通过onmouseover(),和onmouseout()事件来实现,
------------------------------------------------------
<Html>
<Title> 下拉框提示信息 </Title>
<Head>
<SCRIPT LANGUAGE= "JavaScript ">
<!--

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 = document.body.scrollLeft + event.clientX + 16;
  style.top = document.body.scrollTop + 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= ' '> xxxxx </option>
</select>

<!--提示信息层-->
<div id=div_hint style= "font-size:12px;color:red;display:none;position:absolute; z-index:2; top: