0

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

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by scrappedcola
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.