复制代码代码如下:
<Html>
<head>
<type skrip = "Teks/JavaScript">
function showdiv (id) {
document.geteLementById ("selectOption"). style.display = "block";
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;
}
fungsi selectm ()
{
var obj = document.geteLementById ("mySelect");
waspada (obj.selectedIndex);
}
function checkselect (objname) {
o = document.getElementById (objname);
t = document.getElementById ("output");
var intvalue = "";
untuk (i = 0; i <o.length; i ++) {
if (o.Options [i] .poelected) {
intvalue+= o.Options [i] .value+",";
}
}
t.value = intvalue.substr (0, intvalue.length-1);
waspada (intvalue);
}
</script>
</head>
<body>
<sorm>
<Div id = "selectOption" style = 'width: 100px; tinggi: 50px; z-index: 100; Border: 1px solid #0099ff; latar belakang: #cccccc; display: none;'>
<Pilih id = "MySelect" Multiple = "Multiple" size = "4">
<Opsi value = '苹果'> 苹果 </ption>
<Opsi value = '桃子'> 桃子 </ption>
<Opsi value = '香蕉'> 香蕉 </ption>
<Opsi value = '桔子'> 桔子 </ption>
</pilih>
<input type = "tombol" ontClick = "checkselect ('myselect')" value = "checkselect">
</div>
选中的项目 : <input type = "text" name = "output">
<input id = "lalla" type = "tombol" ontClick = "showdiv (this.id)" value = "选择">
<br/>
</form>
<p> 在您点击 "选择多个" 按钮之前 , 请尝试同时选取多个选项。在点击 "选择多个" 按钮之后 , 请再试一次。 </p>
</form>
</body>
</html>