JAVASCRIPT控制下拉列表的全部显示
<select name= "drp1 " onfocus= "javascript:fncDispList(this); ">
<option value= " "> </option>
<option value= "1 "> BEIJING </option>
<option value= "2 "> SHANGHAI </option>
<option value= "3 "> CHONGQING </option>
<option value= "4 "> TIANJIN </option>
</select>
当下列列表获得焦点的时候,用javascript控制整个下拉列表的内容全部弹出来显示给用户,和鼠标单击的效果一样,请高手告诉我如何实现啊?
都研究1天了,郁闷。
------解决方案--------------------L@_@K
<body>
<select name= "drp1 " onfocus= "fncDispList(this); ">
<option value= " "> </option>
<option value= "1 "> BEIJING </option>
<option value= "2 "> SHANGHAI </option>
<option value= "3 "> CHONGQING </option>
<option value= "4 "> TIANJIN </option>
</select>
<script type= "text/javascript ">
<!--
function fncDispList(oSelect)
{
oSelect.size = oSelect.options.length;
}
//-->
</script>
</body>
------解决方案--------------------这个方法可以实现,不过不建议用
<select name= "drp1 " onfocus= "fncDispList(this); ">
<option value= " "> </option>
<option value= "1 "> BEIJING </option>
<option value= "2 "> SHANGHAI </option>
<option value= "3 "> CHONGQING </option>
<option value= "4 "> TIANJIN </option>
</select>
<script>
function fncDispList(){
drp1.focus();
var WshShell = new ActiveXObject( "Wscript.Shell ");
try{
WshShell.SendKeys( "%{DOWN} ");
}
catch(e){}
WshShell.Quit;
}
</script>
------解决方案-------------------- <body>
<table border= "1 ">
<tr>
<td valign= "top "> BigCity </td>
<td>
<select id= "selBigCity " onmouseover= "showAll() ">
<option value= " "> </option>
<option value= "1 "> BEIJING </option>
<option value= "2 "> SHANGHAI </option>
<option value= "3 "> CHONGQING </option>
<option value= "4 "> TIANJIN </option>
</select>
</td>
</tr>
<tr>
<td> 实现 </td>
<td> 按 Tab 键焦点移动至 Select 时,选项自动展开,按首字母可实现选择同时确认,上
下方向键移动,空格或回车键确认! </td>
</tr>
<tr>
<td> 问题 </td>
<td> 俺尝试不让 td 被撑开