我有2个按钮。一种是将项目添加到列表框中。另一个是从列表框中删除某些内容。填充物发生在数组中。那么,我需要知道的是:如何从列表框中删除选定的项目?

谢谢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