Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Populate list in HTA with array

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,49908
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Populate list in HTA with array
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Populate list in HTA with array - 7/24/2007 6:38:09 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
How do I populate a list in an HTA dynamically based on options that a user selects?  I have a script that lists 100+ servers and  I would like to enable the user to filter the list based on choices given.

Would it require the script to write a new hta and reload it with the filtered list of options to the user? I think in ASP it would just be a page refresh with response.write, but I'm not sure. I am pretty good at VBScript, but a novice at GUIs. Normally I would just do this with msgbox prompts, but I would like to create a more refined tool for other admins on our team to use.

 
 
Post #: 1
 
 RE: Populate list in HTA with array - 7/24/2007 7:06:24 AM   
  mcds99


Posts: 441
Score: 4
Joined: 2/28/2006
Status: offline
I did this HTA (with help from the forums here) that has way to much going on on the screen 8-O, I had to chop it in to smaller parts ;-)
It's for Little League Baseball coaches, I don't know if I posted it...

It uses an HTML drop down list that loads when the HTA runs...

   Function window_onload
      code to run when starting HTA
   END Function

When the list is populated you do an HTML select...

   <Select name="TeamSelect" onChange="Team"></select>

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to CondoPC)
 
 
Post #: 2
 
 RE: Populate list in HTA with array - 7/24/2007 7:07:19 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
Just make sure that you give the list object an id property. Then you can update it's contents whenever you want.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to CondoPC)
 
 
Post #: 3
 
 RE: Populate list in HTA with array - 7/24/2007 2:03:16 PM   
  dm_4ever


Posts: 2724
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
This would be a useful site when working with HTA's: http://www.w3schools.com/htmldom/default.asp

Simple example and you should be able to find other's here.


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to CondoPC)
 
 
Post #: 4
 
 RE: Populate list in HTA with array - 7/25/2007 1:34:31 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
OK, this worked well, Thanks!

Now on to the next problem created:
I made the select list (or any select list) able to accept multiple selections. How do I get the values from that? I first tried the following code and only got one server, even though I selected more than one.
 

'verify values and present for testing
msgbox "Servers: " & cbxServers.value

~...
<td>
<!-- options are populated via script based on environment selection -->
<select name="cbxServers" size="8" multiple="true"></select>
</td>
...~

 
So then I tried the following and get errors because it's not valid to do this (I was just guessing):

strServersPicked = cbxServers.value(0) &
"," & cbxServers.value(1)
'verify values and present for testing
msgbox "Servers: " & strServersPicked
 
 


As a side note, I also noted that my scroll bar does not appear (even though it works) when I build the select list dynamically as suggested. It's not a show stopper, just a glitch. Any one else experience this?
 
 

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: Populate list in HTA with array - 7/25/2007 2:55:49 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
You will need to loop through the collection to find selected items. 
 
   For Each objOption In cbxServers.Options
       If objOption.Selected Then

            'do something with objOption.Text or objOption.Value
       End If
   Next


_____________________________

Rischip
Author of - The Grim Linker

(in reply to CondoPC)
 
 
Post #: 6
 
 RE: Populate list in HTA with array - 7/25/2007 3:20:54 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
Thanks, That worked great. Now if I could fix the scroll bar, but no biggie. Thanks all for your help!!

(in reply to Rischip)
 
 
Post #: 7
 
 RE: Populate list in HTA with array - 7/25/2007 3:28:18 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
Define "Fix" and show the code you are using to dynamically create the options.

< Message edited by Rischip -- 7/25/2007 3:40:59 AM >


_____________________________

Rischip
Author of - The Grim Linker

(in reply to CondoPC)
 
 
Post #: 8
 
 RE: Populate list in HTA with array - 7/25/2007 3:44:44 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
Try this

~...
<td>
<!-- options are populated via script based on environment selection -->
<select name="cbxServers" size="8" multiple></select>
</td>
...~

instead of this

~...
<td>
<!-- options are populated via script based on environment selection -->
<select name="cbxServers" size="8" multiple="true"></select>
</td>
...~

_____________________________

Rischip
Author of - The Grim Linker

(in reply to Rischip)
 
 
Post #: 9
 
 RE: Populate list in HTA with array - 7/25/2007 4:18:46 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
yes, i caught that and corrected it. That didin't solve the scrollbar issue though. I think it is because of styles. When I pulled the code out into another script to paste into here, it works as expected and the scrollbar appears. It probably is table inheritance and formatting issues, or the styles that I define in my script. I am pretty sure I can troubleshoot it.

Again, it isn't any big issue because the main purpose of the script works.


      

(in reply to Rischip)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Populate list in HTA with array Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts