复制代码代码如下:
<html>
<Evista>
<script type = "text/javaScript">
función showDiv (id) {
document.getElementById ("selectOption"). style.display = "bloque";
document.getElementById ("selectOption"). style.position = "Absolute";
document.getElementById ("selectOption"). style.top = document.getElementById (id) .OffSettop+25;
document.getElementById ("selectOption"). style.left = document.getElementById (id) .OffSetleft+20;
}
función selectM ()
{
var obj = document.getElementById ("mySelect");
alerta (obj.selectedIndex);
}
función checkSelect (objname) {
o = document.getElementById (objname);
t = document.getElementById ("salida");
var intValue = "";
para (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>
</ablo>
<Body>
<form>
<div id = "selectOption" estilo = 'ancho: 100px; altura: 50px; z-odex: 100; border: 1px sólido #0099ff; fondo: #ccccccc; display: none;'>
<select id = "myselect" múltiple = "múltiple" size = "4">
<opción valor = '苹果'> 苹果 </opción>
<opción valor = '桃子'> 桃子 </opción>
<opción valor = '香蕉'> 香蕉 </opción>
<opción valor = '桔子'> 桔子 </opción>
</select>
<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/>
</form>
<p> 在您点击 “选择多个” 按钮之前 , 请尝试同时选取多个选项。在点击 “选择多个” 按钮之后 , 请再试一次。 </p>
</form>
</body>
</html>