<script language="javascript" type="text/javascript">
function ListSwapNode(tNowIndex, tIndex, tList) {
var tSelectedIndex = tNowIndex;
var tListOptions = tList.options;
//check swap's item exist or not
if (tSelectedIndex + tIndex >= 0 && tListOptions[tSelectedIndex + tIndex] && tListOptions[tSelectedIndex]) {
//swapNode
tListOptions[tSelectedIndex + tIndex].swapNode(tListOptions[tSelectedIndex]);
}
}
// sort listitem
function Sort(pAction) {
//debugger;
var tSortField = document.getElementById("DefaultContent_ListBox1"); //sort feilds
var tSelectedIndex = tSortField.selectedIndex;
//if not select any one.
if (tSelectedIndex == -1) {
return;
}
else {
for (var i = 0; i < tSortField.options.length; i++) {
if (tSortField.options[i].selected == true) {
if (pAction == 'Up') {
//up
ListSwapNode(i, -1, tSortField);
}
else {
//down
ListSwapNode(i, +1, tSortField);
}
break;
}
}
}
}
$(document).ready(function (pAction) {
Sort(pAction);
});
</script>
javascript 对listbox 排序
最新推荐文章于 2021-03-10 01:42:21 发布