Click to See Complete Forum and Search --> : Move data between select boxes


simonfinn
11-05-2003, 04:28 AM
Hi

I am using this code (which i got from this website: http://www.mattkruse.com/javascript/selectbox/source.html) to move data between select boxes

I get two errors, one: the function does not work and two: i get the error "missing ')' " on the head tag

Any help would be great

Thanks Si.



I am calling the function like this:

INPUT onclick="moveSelectedOptions(document.myForm.clients2, document.myForm.clients1)" type=button value="Exclude

AND

INPUT onclick="moveSelectedOptions(document.myForm.clients1, document.myForm.clients2)" type=button value="Exclude

Here is the function:

function moveSelectedOptions(from,to)
{
// Unselect matching options, if required
if (arguments.length>3) {
var regex = arguments[3];
if (regex != "") {
unSelectMatchingOptions(from,regex);
}
}
// Move them over
for (var i=0; i<from.options.length; i++) {
var o = from.options[i];
if (o.selected) {
to.options[to.options.length] = new Option( o.text, o.value, false, false);
}
}
// Delete them from original
for (var i=(from.options.length-1); i>=0; i--) {
var o = from.options[i];
if (o.selected) {
from.options[i] = null;
}
}
if ((arguments.length<3) || (arguments[2]==true)) {
sortSelect(from);
sortSelect(to);
}
from.selectedIndex = -1;
to.selectedIndex = -1;
}

Khalid Ali
11-05-2003, 07:20 AM
Take a look at this resouce (http://www.webapplikations.com/pages/html_js/forms/AddRemovValuesFromListBox.html) resource, I think it should give you some answers