문제

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

도움이 되었습니까?

해결책

<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'>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top