function sortLeftlist() {
var lb = document.getElementById('JWP_UIWT_swapper1_leftSelect');
var itemList = [];
for(i=0; i<lb.options.length; i++)
itemList[i] = {text:lb.options[i].text, title:lb.options[i].title};
itemList.sort(function(a, b) {
return a.text < b.text ? -1 : a.text == b.text ? 0 : 1;
});
for(i=0; i<itemList.length; i++) {
lb.options[i].text = lb.options[i].value = itemList[i].text;
lb.options[i].title = itemList[i].title;
}
}
While I have scanned the above code most carefully, I don't have the infrastructure to test it before sending it to you.
Good luck.
On Wednesday, November 20, 2013 2:12:34 AM UTC-5, Sia wrote:
Hi, I have 2 listboxes (Items can moves between them) and i need to display the text description/title for each item when mouse over. How do i sort the description/title according to thier item after the item moved.I have set the moved item located at the bottom of the list first. Then i will sort them after that. However i do not know how to sort the mouse over description/title according to their items.Remind : Description/title must tie to its item.Please help. Thanks.function JWP_UIWT_swap(inSrc, inAll) {if (inSrc == JWP_UIWT_LEFT) {oSrc = document.getElementById("JWP_UIWT_swapper1_leftSelect"); oDest = document.getElementById("JWP_UIWT_swapper1_rightSelect"); } else {oSrc = document.getElementById("JWP_UIWT_swapper1_rightSelect"); oDest = document.getElementById("JWP_UIWT_swapper1_leftSelect"); }for (i = 0; i < oSrc.options.length; i++) {oOpt = oSrc.options[i];if (oOpt.selected || inAll) {oNew = new Option(oOpt.text , oOpt.value);oNew.title = oOpt.title;oDest.options[oDest.options.length] = oNew; oSrc.remove(i);i--;}}}function sortLeftlist() {var lb = document.getElementById('JWP_UIWT_swapper1_leftSelect'); arrTexts = new Array();arrTitle = new Array();for(i=0; i<lb.length; i++) {arrTexts[i] = lb.options[i].text;arrTitle[i] = lb.options[i].title;}arrTexts.sort();for(i=0; i<lb.length; i++) {lb.options[i].text = arrTexts[i];lb.options[i].value = arrTexts[i];lb.options[i].title = arrTitle[i];}}
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.