tags:

views:

131

answers:

1

I got 2 buttons. One is to add an item to the listbox. The other is to delete something out of the listbox. The filling happens with an array. So what I need to know is: how can i delete a selected item out of the listbox?

Thanks Stijn

A: 
<script type='text/javascript'>
function removeItem(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
if(selectbox.options[i].selected)
selectbox.remove(i);
}
}
</script>

<SELECT id="item" NAME="item" MULTIPLE size=6 width=10></SELECT>
<input type=button onClick="removeItem(item)"; value='Remove Selected Item'>
RSK
thanks for post. It works.
stijn
I still got a problem: When I tried the code in a separate file it worked perfect. But when i tried to integrate it in my index.php it did not work. Any suggestions? Thanks
stijn
post your code here
RSK
found the solution a collegue of mine helped. Thanks for the help Sathsih
stijn