复制代码代码如下:
<html>
<head>
<script type = "text/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;
}
functionselectm()
{
var obj = document.getElementById( "mySelect");
アラート(obj.selectedindex);
}
function 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);
アラート(intvalue);
}
</script>
</head>
<body>
<form>
<div id = "selectoption" style = 'width:100px; height:50px; z-index:100; border:1px solid#0099ff; background:#cccccc; display:none;'>
<選択id = "mySelect"倍数= "倍数" size = "4">
<オプション値= '苹果'> </option>
<オプション値= '桃子'> </option>
<オプション値= '香蕉'> </option>
<オプション値= '桔子'> </option>
</select>
<入力型= "button" onclick = "checkselect( 'myselect')" value = "checkselect">
</div>
选中的项目:<入力タイプ= "text" name = "output">
<入力id = "lalla" type = "button" onclick = "showdiv(this.id)" value = "选择">
<br/>
</form>
<p>在您点击 "选择多个”按钮之前、请尝试同时选取多个选项。在点击"选择多个”按钮之后、请再试一次。</p>
</form>
</body>
</html>