Re: Using and Array in an HTA by Rajeev
Rajeev
Fri Aug 31 11:02:02 PDT 2007
You know, I was going over this code witha co-worker and realized I had
removed the code for the drop down. I re-added it and found the error in my
code.
If objDictionary.Exists(strdnsRoot) Then
objDictionary.Add strdnsRoot, strdnsRoot
End If
The code above SHOULD have been:
If not objDictionary.Exists(strdnsRoot) Then
objDictionary.Add strdnsRoot, strdnsRoot
End If
Thanks for your help!
"mr_unreliable" wrote:
> Rajeev, I would say that you want to create an option tag
> for each item you are adding to your drop-down.
>
> Instead of:
>
> ServerSuccess.innerHTML = strKeys
>
> Try this (assuming that the outer html is a select/end select tag):
>
> Dim sOptions : sOptions = ""
>
> For Each strKeys in objDictionary.Keys
> sOptions = sOptions & "<option>" & strKeys & "</option>" & vbCrLf
> Next
>
> ServerSuccess.innerHTML = sOptions
>
> There are probably many other ways to do this. If you
> wish to plug the options in one-by-one, take a look
> at the dhtml "insertBefore" method.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
>
> Rajeev wrote:
> > I've taken one of my vbscripts that pre-creates computer accounts in the
> > proper OU and threw it into an HTA. The script works quite well, but I'd
> > like to make the domain selection drop down more dynamic. I've managed to
> > get a list of the root domain and all it's child domains, but I need to
> > filter out some duplicates before it goes into the drop down.
> >
> > What I've done is put all the data into an array and used the following code
> > to filter out duplicates:
> >
> > Do Until objRecordSet.EOF
> > strdnsRoot = join(objRecordSet.Fields("dnsRoot").Value)
> > If objDictionary.Exists(strdnsRoot) Then
> > objDictionary.Add strdnsRoot, strdnsRoot
> > End If
> > objRecordSet.MoveNext
> > Loop
> >
> > The code works as it's suppose to, but when I try and dump it into the
> > dropdown, nothing happens.
> >
> > For Each strKeys in objDictionary.Keys
> > ServerSuccess.innerHTML = strKeys
> > Next
> >
> > If I dump this in a standard vbscript and use wscript.echo to output the
> > data it works properly. Am I missing something? Thanks.
>