<select id="a" multiple>
<option value="1" >1
<option value="2">1
<option value="3">1
<option value="4">1</select>
<input type=button onclick="aa()">
<script>
function aa(){
var s = "";
for(var i=0;i<document.all.a.options.length;i++)
{
if(document.all.a.options[i].selected)
{s += document.all.a.options[i].value;}
}
alert(s);}
</script>
<option value="1" >1
<option value="2">1
<option value="3">1
<option value="4">1</select>
<input type=button onclick="aa()">
<script>
function aa(){
var s = "";
for(var i=0;i<document.all.a.options.length;i++)
{
if(document.all.a.options[i].selected)
{s += document.all.a.options[i].value;}
}
alert(s);}
</script>
如是在页面用js, wangxj0600(闭门思过中) 的例子就行了
如是提交到asp,则提交的已是数组
如市提交到php,需将select的名字以数组形式表示,提交后也是数组
<option value="1" >1
<option value="2">1
<option value="3">1
<option value="4">1</select>
<input type=button onclick="aa()">
<script>
function aa(){
var s = new Array();
var j = 0;
for(var i=0;i<document.all.a.options.length;i++)
{
if(document.all.a.options[i].selected)
{s[j++] += document.all.a.options[i].value;}
}
alert(s.length);}
</script>
<option value="1" >1
<option value="2">1
<option value="3">1
<option value="4">1</select>
<input type=button onclick="aa()">
<script>
function aa(){
var s = new Array();
var j = 0;
for(var i=0;i<document.all.a.options.length;i++)
{
if(document.all.a.options[i].selected)
{s[j++] += document.all.a.options[i].value;}
}
alert(s);}
</script>