<?php
if(isset($_POST["selectmultiple"])!=""){
//$a=explode(",",$_POST["selectmultiple"]);
//print_r($a);
// for($i=0;$i<count($a);$i++){
// echo $a[$i]."<br/>";
echo $_POST["selectmultiple"];
// }
}
?>
<script language=javascript>
function getMultiple(ob)
{
var arSelected = new Array();
arSelected = new Array();
while (ob.selectedIndex != -1)
{
arSelected.push(ob.options[ob.selectedIndex].value);
ob.options[ob.selectedIndex].selected = false;
}
// You can use the arSelected array for further processing.
document.getElementById("selectmultiple").value=arSelected.toString();
document.frmSelect.action="";
document.frmSelect.submit();
}
</script>
<form name='frmSelect' action="" method="post">
<select name='numbers' multiple='multiple' style="height:180px;">
<?php
for($i=1;$i<=10;$i++){
?>
<option value="<?=$i;?>"> <?=$i;?></option>
<?php
}
?>
</select>
<input type="hidden" name="selectmultiple" id="selectmultiple">
<input type='button' value='Submit' onclick="getMultiple(document.frmSelect.numbers);" />
</form>