I have a javascript function that will help you:
Now its up to you to figure out how to use it 🙂
You'll probably want to use a button or link and upon click, determine the "selectedIndex" property of the listbox with which you use the function below.
Create two wrapper function named "demote" and "promote" who will do the error checking for you.
function switchElements( hList, nFirst, nSecond )
{
/
Switches the positions of the options at
[nFirst] and [nSecond]
/
var l_FirstOption = new Option( hList.options[ nFirst ].text, hList.options[ nFirst ].value );
var l_SecondOption = new Option( hList.options[ nSecond ].text, hList.options[ nSecond ].value );
hList.options[ nSecond ] = l_FirstOption;
hList.options[ nFirst ] = l_SecondOption;
}
//This probably will come in handy too !
function addElement( hList, sValue, sLabel )
{
/*
Creates an option object and pushes it
onto end of [hList]
<option value = 'sValue'> sLabel </option>
*/
var Item = new Option( sLabel, sValue );
eval( "hList.options[ hList.length ] = Item" );
}
// So will this...
function removeElementAt( hList, nIndex )
{
/ Removes element at [nIndex] from list /
hList.options[ nIndex ] = null;
}