Link to home
Start Free TrialLog in
Avatar of ezsas
ezsasFlag for Canada

asked on

Clear selected items in list box using Javascript

I have one html form that uses 7 list boxes. I want to clear mulitple selected items in one list box not all. How can I do that?

Thanks
Ezsas
Avatar of hielo
hielo
Flag of Wallis and Futuna image

try:
function clearSelect(s){
	s = document.getElementById(s);
	if(s)
		s.selectedIndex=-1;
}

so if you want to clear:
<select id='countries' ...>...</select>

then call it as:
clearSelect('countries')

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mangagm
Mangagm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial