复制代码代码如下:
<html>
<head>
<script type = "text/javascript">
função showdiv (id) {
document.getElementById ("selectOption"). style.display = "bloco";
document.getElementById ("selectOption"). style.position = "absoluta";
document.getElementById ("selectOption"). style.top = document.getElementById (id) .offsetTop+25;
document.getElementById ("selectOption"). style.left = document.getElementById (id) .offsetleft+20;
}
função selectM ()
{
var obj = document.getElementById ("MySelect");
alerta (obj.SelectedIndex);
}
função checkSelect (objName) {
o = document.getElementById (objName);
t = document.getElementById ("output");
var intvalue = "";
for (i = 0; i <o.length; i ++) {
if (O.Options [i] .Selected) {
intvalue+= o.options [i] .Value+",";
}
}
t.value = intvalue.substr (0, intvalue.length-1);
alerta (intvalue);
}
</script>
</head>
<Body>
<morm>
<div id = "selectOption" style = 'Largura: 100px; altura: 50px; z-index: 100; borda: 1px sólido #0099ff; fundo: #ccccc; display: nenhum;'>>
<select id = "mySelect" múltiplo = "múltiplo" size = "4">
<opção value = '苹果'> 苹果 </pption>
<opção value = '桃子'> 桃子 </pption>
<opção value = '香蕉'> 香蕉 </pption>
<opção value = '桔子'> 桔子 </pption>
</leclect>
<input type = "button" onclick = "checkSelect ('mySelect')" value = "checkSelect">
</div>
选中的项目 : <input type = "text" name = "output">
<input id = "lalla" type = "button" onclick = "showdiv (this.id)" value = "选择">>
<br/>
</morm>
<p> 在您点击 “选择多个” 按钮之前 , 请尝试同时选取多个选项。在点击 “选择多个” 按钮之后 , 请再试一次。 </p>
</morm>
</body>
</html>