Avatar of ezsas
ezsas
Flag 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
JavaScript

Avatar of undefined
Last Comment
Mangagm

8/22/2022 - Mon
hielo

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
Mangagm

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61