Thx for previous help to get this thing working. Just learned that sorting is now a requirement. I’ve tried several variations of code using sort() but can’t seem to get it to work. Not sure if it’s even possible. If anyone can help it’d be much appreciated.
All I need the below function to do is sort each of 2 lists alphabetically when items are moved from one side to the other. If you cut/paste the code below you should instantly see what I mean by this.
Anyway, thanks in advance!
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function moveOver(fromList,toList,limit)
{
var undefined;
var boxLength = toList.length;
var selectedItem = fromList.selectedIndex;
var selectedText = fromList.options[selectedItem].text;
var selectedValue = fromList.options[selectedItem].value;
var i;
var isNew = true;;
if ( ((limit != undefined) && (boxLength<limit)) || limit == undefined ) {
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = toList.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
toList.options[boxLength] = newoption;
}
fromList.options[selectedItem] = null;
fromList.selectedIndex=-1;
} else {
alert(“This is a limit of ” + limit + ” choices for this list.”);
}
}
</SCRIPT>
<form>
All Available Users:
<select multiple name=”userID” style=”width:275;” size=”6″ onchange=”moveOver(this,this.form.list);”>
<option>Option1</option>
<option>Option2</option>
<option>Option3</option>
<option>Option4</option>
</select>
Users in this Group:
<select multiple name=”list” style=”width:275;” size=”6″ onchange=”moveOver(this,this.form.userID);”>
<option>Option6</option>
<option>Option7</option>
<option>Option8</option>
<option>Option9</option>
</select>
</form>