Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to remove all item ?

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
0
0
FR
hi all
i do have a mutiple select box and an array. i need to make a function that will remove all the things i have added.
when i added my items i incremented a var called number

Code:
function add() 
{ 

boxSelectedCond.options[number] = new Option(toto + " " + tata + " " + tutu ,number);
storeQuery[number]= new Array(toto,tata,tutu);
number ++;
}
and here is my delete function that is not working:
Code:
	for (i=0; i<number;i++)
	{
		document.forms[0].Sel_cond.options[i]= null;
		storeQuery[i] = new Array();
	}
what's wrong ?

Best regards X-),
Elise
 
Try this
Code:
for (var i=document.forms[0].Sel_cond.options.length-1; i>=0; i--)
{
  document.forms[0].Sel_cond.options[i] = null;
}
document.forms[0].Sel_cond.selectedIndex = -1;
 
thanks ! Best regards X-),
Elise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top