Re: Sort problem

Wednesday, November 20, 2013

Thanks a lot. It works =D 

On Thursday, November 21, 2013 4:25:47 AM UTC+8, Binary Tutor wrote:
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;

   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;


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
For more options, visit


Post a Comment

Note: Only a member of this blog may post a comment.

Copyright © 2010 Web Design | Free Blogger Templates by Splashy Templates | Layout by Atomic Website Templates

Vida de bombeiro Recipes Informatica Humor Jokes Mensagens Curiosity Saude Video Games Animals Diario das Mensagens Eletronica Rei Jesus News Noticias da TV Artesanato Esportes Noticias Atuais Games Pets Career Religion Recreation Business Education Autos Academics Style Television Programming Motosport Humor News The Games Home Downs World News Internet Design Entertaimment Celebrities 1001 Games Doctor Pets Net Downs World Enter Jesus Mensagensr Android Rub Letras Dialogue cosmetics Genexus lasofia thebushrajr wingshock tripedes gorduravegetal dainfamia dejavu-transpersonal jsbenfica republicadasbadanas ruiherbon iranianforaryans eaystcheyl fotosdanadir Só Humor Curiosity Gifs Medical Female American Health Madeira Designer PPS Divertidas Estate Travel Estate Writing Computer Matilde Ocultos Matilde futebolcomnoticias girassol lettheworldturn topdigitalnet Bem amado enjohnny produceideas foodasticos cronicasdoimaginario downloadsdegraca compactandoletras newcuriosidades blogdoarmario arrozinhoii