KS_Mis
asked on
ListBox delete all selected items
Hi,
I am trying to delete all the selected items in the listbox.
I am not sure what I am doing wrong.
here is my code:
function DoRemove()
{
var sourceListBox = document.getElementById('c tl00_Conte ntPlaceHol der1_GetLi stOfLocati on');
var List = sourceListBox.options.leng th;
selectedIndex=null;
if (sourceListBox != null)
{
for (var i=0; i < List; i++)
{
// if (sourceListBox.options[i]. selected)
if (sourceListBox.Selected[i] ) then
{
// sourceListBox.remove(sourc eListBox.o ptions.sel ectedIndex );
//sourceListBox.remove(sou rceListBox .options[i ].selected Index);
//sourceListBox.Items.Dele te(i);
}
}
}
}
the error says: 'options[...].selected' is null or not an object.
Thanks,
I am trying to delete all the selected items in the listbox.
I am not sure what I am doing wrong.
here is my code:
function DoRemove()
{
var sourceListBox = document.getElementById('c
var List = sourceListBox.options.leng
selectedIndex=null;
if (sourceListBox != null)
{
for (var i=0; i < List; i++)
{
// if (sourceListBox.options[i].
if (sourceListBox.Selected[i]
{
// sourceListBox.remove(sourc
//sourceListBox.remove(sou
//sourceListBox.Items.Dele
}
}
}
}
the error says: 'options[...].selected' is null or not an object.
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
ASKER
var List = sourceListBox.options.leng
selectedIndex=null;
if (sourceListBox != null)
{
for (var i=0; i < List; i++)
{
if (sourceListBox.options[i].
{
sourceListBox.remove(sourc
}
}
}
}