Moving Up and down Options in Multiple select box
<p>There is a logical error in the code..
we cannot  move up or down 2 or more options at a time.Only 1 option at a time can be moved up or down..so how to make 2 or more options move up and down when selected...</p>

<pre><code>function listbox_move(listID, direction) {
    var listbox = document.getElementById(listID);
    var selIndex = listbox.selectedIndex;

    if(-1 == selIndex) {
        alert("Please select an option to move.");
        return;
    }

    var increment = -1;
    if(direction == 'up')
        increment = -1;
    else
        increment = 1;

    if((selIndex + increment) &lt; 0 ||
        (selIndex + increment) &gt; (listbox.options.length-1)) {
        return;
    }

    var selValue = listbox.options[selIndex].value;
    var selText = listbox.options[selIndex].text;
    listbox.options[selIndex].value = listbox.options[selIndex + increment].value
    listbox.options[selIndex].text = listbox.options[selIndex + increment].text

    listbox.options[selIndex + increment].value = selValue;
    listbox.options[selIndex + increment].text = selText;

    listbox.selectedIndex = selIndex + increment;

}
</code></pre>

<p>And I call it as follows</p>

<pre><code>listbox_move('countryList', 'up'); //move up the selected option
listbox_move('countryList', 'down'); //move down the selected option
</code></pre>

<p>Thank you in advance.... :)</p>
