We help IT Professionals succeed at work.
Get Started

HTA / HTML help - How to clear a drop down list (remove ALL items)

Last Modified: 2012-05-06
I'm dynamically generating a table in my script code that creates a cell with a text box, using the following...

<INPUT TYPE=text NAME=txtTargetServer SIZE=25 OnKeyUp=""UpdateTargetServer"" onBlur=""UpdateTargetDrives"" TITLE=""Enter the target server name only."">

When the text value is entered, the onBlur event fires and the drop down (which calls a wmi query to get the server's volume) is correctly populated.
However, if I revisit that field and change the server, it's not properly clearing the options in the drop down.

As a test, I entered msgbox lines and it comes up as 0 for the length after the while/wend loop, but the data is still there - do I have to refresh the list somehow?

I've also tried this loop, which fails to ever hit (it's after the while/wend)
   For Each objOption in TargetVolumes.Options

msgbox TargetVolumes.Options.Length
  While TargetVolumes.Options.Length > 0
msgbox TargetVolumes.Options.Length

Open in new window

Watch Question
Most Valuable Expert 2012
Top Expert 2014
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE