locked
Arrays in HTAs RRS feed

  • Question

  • Hello all,

    First things first, I am just not good at deriving code.  I've been trying and trying to get what I am trying to do to work, but not having any luck.  What frustrates me is that I know what I am trying to accomplish is super easy for the pros.  If anyone could provide some guidance, I'd be much appreciated!

    The Situation:

    I have an HTA with a Listbox of Locations (countries).  I have another DropDown that I would like to populate based on the selection of the country from the ListBox with cities from that country that can be selected.  Then, based on the selection from the DropDown, I need to set a variable called "Prefix".

    I know this will require an array or arrays to populate the DropDown.  I have multiple values for different countries based on the selection of the user.  For example, if a user selects United States as their country, I would like Los Angeles, New York, Boston populated into the DropDown.  Then, if the user selects Los Angeles, set the variable "Prefix" to "LOS".  If the user selects New York, set the variable "Prefix" to "NYC", etc.  Extending the example, if a user selects Brazil as their country, I would like Buenos Aires, Rio de Janeiro populated in the DropDown.  Then, if the user selects Buenos Aires, set the variable "Prefix" to "BUE".  If the user selects Rio de Janiero, set the variable "Prefix" to "RDJ".

    I have many countries to do this for.  My original logic was to create all the arrays with the city values needed and then used IF statements to dynamically load the array into the DropDown.  But, it's not working.

    Here is the code of the HTA:

    NOTE - I have not attempted to code the 3rd aspect of what I am trying to do which is setting the "Prefix" variable based on the City selection yet.  I think I have a general idea of what to do, but if anyone has suggestions on that aspect, that'd be great too.  Told you I wasn't good at this, haha!

    Thanks to all who took time to read this and help me out!

    -MDH

    HTA Code:

    <head>
    <title>Test</title>
    <HTA:APPLICATION
         APPLICATIONNAME="Test"
         SCROLL="yes"
         SINGLEINSTANCE="yes"
         WINDOWSTATE="maximize"
    </head>

    <SCRIPT LANGUAGE="VBScript">

    'Hides Task Sequence Progress
    Set ProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
    ProgressUI.CloseProgressDialog

    'Sets up actions to follow clicking on run
    Sub ButtonFinish
    SET TSenv = CreateObject("Microsoft.SMS.TSEnvironment")
    'Sets PC Name       
     'msgbox "PC NAME "& computername.Value &""
            TSenv("OSDComputerName") = computername.Value

    'Closes window
    window.Close

    End Sub

    Sub RunScript
    SET TSenv = CreateObject("Microsoft.SMS.TSEnvironment")
    'MsgBox Listbox1.Value - will return/pass value in listbox value code below to MUI variable
    TSenv("MUI") = Listbox1.Value
    Call CreateArrays()
    Call SetSite()

    End Sub

    Sub CreateArrays

    Dim NAArray, SAArray, EUArray, x, objOption
    NAArray = Array("Los Angeles", "New York", "Boston")
    SAArray = Array("Buenos Aires", "Rio de Janeiro")
    EUArray = Array("London", "Lisbon", "Berlin")

    End Sub

    Sub SetSite


    If Listbox1.Value="United States" THEN
    For Each x in NAArray
     Set objOption=window.document.createElement("option")
     objOption.value = x
     objOption.text = x
     window.document.getElementByID("Dropdown1").add(objOption)
    Next
    End if

    If Listbox1.Value="Brazil" THEN
    For Each x in SAArray
     Set objOption=window.document.createElement("option")
     objOption.value = x
     objOption.text = x
     window.document.getElementByID("DropDown1").add(objOption)
    Next
    End if

    End Sub

    </SCRIPT>

    <body>
    <br> <b> Computer Name </b> </br>
    <input type=text id="computerName" name=computerName size=40><p>
    <br> <b> Please select your Country </b> </br>
    <p></p>
    <select size="12" name="Listbox1" onChange="RunScript">
    <option value="United States">United States</option>
    <option value="Sweden">Sweden</option>
    <option value="Spain">Spain</option>
    <option value="France">France</option>
    <option value="Germany">Germany</option>
    <option value="Netherlands">Netherlands</option>
    <option value="Japan">Japan</option>
    <option value="Finland">Finland</option>
    <option value="Italy">Italy</option>
    <option value="Argentina">Argentina</option>
    <option value="Portugal">Portugal</option>
    <option value="Brazil">Brazil</option>
    </select>
    &nbsp;&nbsp;&nbsp;&nbsp;
    Please Select Your City:
    <select name="DropDown1"> </select>
    <br></br>
    <input id=runbutton type="button" value="Continue" name="run_button"  onClick="ButtonFinish">
    <br></br>
    <br></br>
    </body>


    • Edited by mdh1983 Wednesday, April 24, 2013 1:36 AM nr
    • Moved by Youen Zen Thursday, April 25, 2013 4:40 AM From Visual Basic
    Wednesday, April 24, 2013 1:32 AM

Answers

All replies