var result = new Array(3)
for(var i = 0 i < result.length i++){
result[i] = arr.splice(Math.random()*arr.length>>>0, 1)[0]
}
console.info(result)
select标记有一个属性multiple,将其设置成multiple="multiple"按住Ctrl键即可实现多选。 请看例子:<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function getValue()
{
var s = ""
for(var i=0i<form1.ss.options.lengthi++)
{
if(form1.ss.options[i].selected)
{
s+=form1.ss.options[i].value
}
}
alert(s)
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
请选择:
<select id="ss" name="ss" size="5" multiple="multiple">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
<br>
<input type="button" name="Submit" value="提交" onclick="getValue()" />
</form>
</body>
</html>
**************************补充**********************
修改select标签的size属性,把它的值改为1即可。
<select multiple="multiple"><option>...</option>
...
</select>
按住ctrl点击左键即可多选