Re: Set a drop down to a certain selection



Hi Tom,

Sorry, it is in an HTA, and your solution works perfectly, thanks!


"Tom Lavedas" wrote:

On May 16, 11:26 am, XP <X...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I need to set the selection in a drop down box (not a combo) to a certain
selection based upon a value in a variable:

dropdown1.Value = myVar

doesn't work; what is the correct syntax to set the selector?

Thanks much in advance.

What is the application? There are a lot of 'dropdowns' out there
with different object models. The HTML/DHTML Select object is one
such dropdown and it uses a 'selected' property to do what you
want ...

for each opt in dropdown.options
if lcase(opt.text) = lcase(myVar) then opt.selected = true
next

Other applications may use a different approach.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

.



Relevant Pages

  • Re: Set a drop down to a certain selection
    ... selection based upon a value in a variable: ... what is the correct syntax to set the selector? ... There are a lot of 'dropdowns' out there ... with different object models. ...
    (microsoft.public.scripting.vbscript)
  • Re: Refer to dynamically generated objects during page load
    ... to generate some multiple selection dropdowns. ... and assign the serialization of the document tree to `innerHTML'. ... listbox B where the contents of this listbox is chosen according to a selection in listbox A. ...
    (comp.lang.javascript)
  • Re: Refer to dynamically generated objects during page load
    ... to generate some multiple selection dropdowns. ... You can manipulate that document ... and assign the serialization of the document tree to `innerHTML'. ...
    (comp.lang.javascript)
  • Re: method to avoid the "screen-flicker-refresh" of postbacks?
    ... i have a section of a page that has multiple dropdowns. ... each dropdown calls the same method on a change of selection by the ... the method loops over all the dropdowns and if the newly ... screen to refresh and display the page at the top (same position as ...
    (microsoft.public.dotnet.framework.aspnet)
  • method to avoid the "screen-flicker-refresh" of postbacks?
    ... i have a section of a page that has multiple dropdowns. ... each dropdown calls the same method on a change of selection by the ... screen to refresh and display the page at the top (same position as ...
    (microsoft.public.dotnet.framework.aspnet)