// Sort: Move Up
Function up ()
...{
VaR sel = Document. getelementbyid ("selectcheck"); // obtain select
VaR nindex = SEL. selectedindex; // index of the select item to be operated
VaR nlen = SEL. length; // total number of select projects
If (nlen <1) | (nindex = 0) return;
If (nindex <0)
...{
Alert ("select a selected button to move! ");
Return;
}
VaR svalue = SEL. Options [nindex]. value;
VaR shtml = SEL. Options [nindex]. innerhtml;
Sel. Options [nindex]. value = SEL. Options [nIndex-1]. value;
Sel. Options [nindex]. innerhtml = SEL. Options [nIndex-1]. innerhtml;
Sel. Options [nIndex-1]. value = svalue;
Sel. Options [nIndex-1]. innerhtml = shtml;
Sel. selectedindex = nIndex-1;
}
// Sort: Move down
Function down ()
...{
VaR sel = Document. getelementbyid ("selectcheck ");
VaR nindex = SEL. selectedindex;
VaR nlen = SEL. length;
If (nlen <1) | (nindex = nLen-1) return;
If (nindex <0)
...{
Alert ("select a selected button to move! ");
Return;
}
VaR svalue = SEL. Options [nindex]. value;
VaR shtml = SEL. Options [nindex]. innerhtml;
Sel. Options [nindex]. value = SEL. Options [nindex + 1]. value;
Sel. Options [nindex]. innerhtml = SEL. Options [nindex + 1]. innerhtml;
Sel. Options [nindex + 1]. value = svalue;
Sel. Options [nindex + 1]. innerhtml = shtml;
Sel. selectedindex = nindex + 1;
}
// Move to the top
Function upfirst ()
...{
VaR sel = Document. getelementbyid ("selectcheck ");
VaR nindex = SEL. selectedindex;
VaR nlen = SEL. Options. length;
If (nlen <1) | (nindex = 0) return;
If (nindex <0)
...{
Alert ("select a selected button to move! ");
Return;
}
VaR tempvalue = Document. getelementbyid ("tempvalue"); // used to temporarily store the option value
Tempvalue. value = "";
For (var k = 0; k <nindex; k ++)
...{
Tempvalue. Value + = SEL. Options [K]. Value + ";";
}
VaR arrvalue = tempvalue. value. Split (';');
VaR svalue = SEL. Options [nindex]. value;
VaR shtml = SEL. Options [nindex]. innerhtml;
Sel. Options [0]. value = svalue;
Sel. Options [0]. innerhtml = shtml;
For (VAR j = 1; j <= nindex; j ++)
...{
Sel. Options [J]. value = arrvalue [J-1];
Sel. Options [J]. innerhtml = arrvalue [J-1];
}
Sel. selectedindex = 0;
}
// Move to the end
Function downlast ()
...{
VaR sel = Document. getelementbyid ("selectcheck ");
VaR nindex = SEL. selectedindex;
VaR nlen = SEL. Options. length;
If (nlen <1) | (nindex = nlen) return;
If (nindex <0)
...{
Alert ("select a selected button to move! ");
Return;
}
VaR tempvalue = Document. getelementbyid ("tempvalue"); // used to temporarily store the option value
Tempvalue. value = "";
For (var k = nindex + 1; k <nlen; k ++)
...{
Tempvalue. Value + = SEL. Options [K]. Text + ";";
}
VaR arrvalue = tempvalue. value. Split (';');
VaR svalue = SEL. Options [nindex]. value;
VaR shtml = SEL. Options [nindex]. innerhtml;
For (var j = nindex; j <nlen; j ++)
...{
Sel. Options [J]. value = arrvalue [J-nindex];
Sel. Options [J]. innerhtml = arrvalue [J-nindex];
}
Sel. Options [nLen-1]. value = svalue;
Sel. Options [nLen-1]. innerhtml = shtml;
Sel. selectedindex = nLen-1;
}