[Project_owners] [XUL&JS] Cant remove from listbox?

Foreningen Selvet - Jesper Staun Hansen jesper at selvet.dk
Wed Aug 15 09:38:10 PDT 2007


I have the following code:

      function movetolist(fromlistid, tolistid) {
    var from = document.getElementById(fromlistid);
    var to = document.getElementById(tolistid);
    dump("I am running! On these: "+from.selectedItems+"\n");
    var items = from.selectedItems;
    for(var key in items) {
        dump("Would add: "+key+"\n");
    }
   
    for(var i=0; items.length > i; i++) {
        dump("I will add: "+items[i].getAttribute('value')+" from: "+ 
fromlistid +" to: "+ tolistid +" key: "+i+"\n");
        
to.appendItem(items[i].getAttribute('label'),items[i].getAttribute('value'));
        items[i].removeItem;     }
    }



This dumps the following when running:
I am running! On these: [object XULElement]
Would add: 0
Would add: max
I will add: networth from: notshow to: doshow key: 0


Now the first for loop does it all wrong, and will always take the very 
first listitem in the listbox.
The other for loop does it right and adds the one listitem to another 
listbox. But! I cant remove it from the original listbox again...
How do i remove it from the originating listbox?



Greets.



More information about the Project_owners mailing list