Link to home
Start Free TrialLog in
Avatar of sirbounty
sirbountyFlag for United States of America

asked on

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

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
       objOption.RemoveNode
    Next

msgbox TargetVolumes.Options.Length
  While TargetVolumes.Options.Length > 0
    TargetVolumes.Options.Remove(0)
  Wend
msgbox TargetVolumes.Options.Length

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

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
Avatar of sirbounty

ASKER

same results...just appends the 'new' to the 'old'... : (
Thanx Rob - it appears it's my goof.
I'd publicly declared an array to hold those volumes...wasn't clearing it out...
Ah cool. Good find.  Thanks for the grade.

Regards,

Rob.