Hi,

This seems really stupid i cant get my head around this.

I have a listbox that has items added to it from selections from another one. I have also added code that an item can be double clicked to remove it, which works, until the page is refreshed and the items all com back.

my code is

function DeleteItem()
    {
 
    var list = document.getElementById("lstSelected");
     var len = list.options.length;
    var i = 0;
   alert(len);
    
    for (i = 0; i < len; i++)
        {
        if(list.options[i].selected)
            {
            alert(document.getElementById("lstSelected")(i).value);
            list.options[i]=null;
            }
           
        }

    }

I wondered if anyone had any ideas

many thanks

Your problem is coming from the fact that the server doesn't know what the client side is doing. You need to save the state of the list box (using SQL or a file) and update that state, through an ajax call or form submit, anytime the client side makes a change to the list box. Here is a tutorial on ajax to get you started.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.