<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function transport(form, from, to)
{
// shorthand
var frm = document.getElementById(form);
var add
= new Array(); // array with text and values of selected items var rem
= new Array(); // list of indexes to remove
// determine items to copy and remove
for(var i=0; i < frm.elements[from].length; i++)
{
if(frm.elements[from].options[i].selected)
{
add
[add
.length
] = new Array(frm
.elements
[from
].options
[i
].text
, frm
.elements
[from
].options
[i
].value
); // to be copied rem[rem.length] = i; // to be removed
}
}
// append selected source to target
for(var i=0; i < add.length; i++)
{
var len = frm.elements[to].length; // current length of target
frm.elements[to].options[len] = new Option(add[i][0], add[i][1]);
}
// remove selected items from source - move back from end to maintain order of indexes
for(var i=(rem.length-1); i > -1; i--)
{
frm.elements[from].remove(rem[i]);
}
}
function spam(form, field)
{
var frm = document.getElementById(form);
for(var i=0; i < frm.elements[field].length; i++)
{
window.alert(frm.elements[field].options[i].text+", "+frm.elements[field].options[i].value);
}
}
</script>
</head>
<body>
<form id="whatever" action="pingpong.html" method="post">
<select name="source" multiple="multiple" size="10" style="width:125px">
<option value="10">Amsterdam</option>
<option value="11">Diemen e.o.</option>
<option value="12">Hilversum</option>
<option value="13">Almere</option>
<option value="14">Bussum</option>
<option value="15">Zaandam</option>
</select>
<button type="button" onclick="transport('whatever', 'destination', 'source')"><</button>
<button type="button" onclick="transport('whatever', 'source', 'destination')">></button>
<select name="destination" multiple="multiple" size="10" style="width:125px">
</select>
<button type="button" onclick="spam('whatever', 'source')">waarden links</button>
<button type="button" onclick="spam('whatever', 'destination')">waarden rechts</button>
</form>
</body>
</html>