Windows Vista Forums

InnerHTML not working

  1. #1


    MattW Guest

    InnerHTML not working

    Hi all. I've got my array working, and pulling data, but my sGroup
    variable isn't populating my innerHTML.

    <HTML>
    <HEAD>
    <TITLE>Users Group Migration HTA</TITLE>
    <HTA:APPLICATION
    ID="MyApp"
    APPLICATIONNAME="Template"
    BORDER="thick"
    BORDERSTYLE="complex"
    CAPTION="yes"
    CONTEXTMENU="no"
    ICON="http://Your URL/your icon.ico"
    INNERBORDER="yes"
    MAXIMIZEBUTTON="yes"
    MINIMIZEBUTTON="yes"
    NAVIGABLE="no"
    SCROLL="no"
    SHOWINTASKBAR="yes"
    SINGLEINSTANCE="yes"
    SYSMENU="yes"
    VERSION="1.0"
    WINDOWSTATE="maximized"/>
    </HEAD>


    <SCRIPT Language="VBScript">
    Dim arrUsers(1)

    ' Size window on load
    Sub Window_onLoad
    window.resizeTo 640, 480
    End Sub

    ' Cancel button
    Sub ExitProgram
    window.close()
    End Sub

    Sub btnComp_Click

    Set WshNetwork = CreateObject("Wscript.Network")
    strDN = WshNetwork.UserDomain
    arrUsers(0) = User1.value
    arrUsers(1) = User2.value
    For i = 0 To 1
    If i = 0 Then
    GetAllGroups(i)
    UserGroup1.InnerHTML = sGroups
    ElseIf i = 1 Then
    GetAllGroups(i)
    UserGroup2.InnerHTML = "Test 2"
    End If
    Next
    End Sub

    Function GetAllGroups(i)
    ' On Error Resume Next
    Set WshNetwork = CreateObject("Wscript.Network")
    strDN = WshNetwork.UserDomain
    sUser = arrusers(i)
    Set objUser = GetObject("WinNT://" & strDN & "/" & sUser)
    For Each oGroup In objUser.Groups
    sGroups = sGroups & oGroup.Name & vbCrLf & "<br>"
    Next
    End Function

    </SCRIPT>
    <body STYLE="font:10pt arial; color:white;
    (background-color:Menu;
    color:MenuText;
    cursor:default">
    <p align=left><b>Group Migration Tool</b></font></p>
    <table>
    <tr>
    <col align="left"></col>
    <col width="160"></col>
    <col align="left"></col>
    <th><b>New User ID.</b></th>
    <th>&nbsp;</th>
    <th><b>Template User ID.</b></th>
    </tr>
    <tr>
    <td><input type="text" name="User1" size=20><p align=left></td>
    <td>&nbsp;</td>
    <td><input type="text" name="User2" size=20><p align=left></td>
    </tr>
    <tr>
    <td><input type="button" value="Compare" name="btnComp"
    onClick="btnComp_Click" STyle='background-color: ButtonFace;'
    STyle='color:ButtonText;'></td>
    <td><input id=runbutton type="button" value="Cancel"
    onClick="ExitProgram" STyle='background-color: ButtonFace;'
    STyle='color:ButtonText;'></td>
    </tr>
    <p>
    <td><Span ID = "DataArea"</Span></td>
    <td><Span ID = "UserGroup1"</Span></td>
    <td><Span ID = "UserGroup2"</Span></td>
    </table>
    </body>
    </html>



    The code works in msgBox, and it writes "Test 2" in the UserGroup2
    InnerHTML as directed, it's just not writing to the InnerHTML that
    I've got set to populate with the variable..

      My System SpecsSystem Spec

  2. #2


    T Lavedas Guest

    Re: InnerHTML not working

    On Jun 12, 4:26*pm, MattW <winber...@xxxxxx> wrote:

    > Hi all. *I've got my array working, and pulling data, but my sGroup
    > variable isn't populating my innerHTML.
    >
    > <HTML>
    > * * * * <HEAD>
    > * * * * * * * * <TITLE>Users Group Migration HTA</TITLE>
    > * * * * * * * * <HTA:APPLICATION
    > * * * * * * * * * * * * ID="MyApp"
    > * * * * * * * * * * * * APPLICATIONNAME="Template"
    > * * * * * * * * * * * * BORDER="thick"
    > * * * * * * * * * * * * BORDERSTYLE="complex"
    > * * * * * * * * * * * * CAPTION="yes"
    > * * * * * * * * * * * * CONTEXTMENU="no"
    > * * * * * * * * * * * * ICON="http://YourURL/your icon.ico"
    > * * * * * * * * * * * * INNERBORDER="yes"
    > * * * * * * * * * * * * MAXIMIZEBUTTON="yes"
    > * * * * * * * * * * * * MINIMIZEBUTTON="yes"
    > * * * * * * * * * * * * NAVIGABLE="no"
    > * * * * * * * * * * * * SCROLL="no"
    > * * * * * * * * * * * * SHOWINTASKBAR="yes"
    > * * * * * * * * * * * * SINGLEINSTANCE="yes"
    > * * * * * * * * * * * * SYSMENU="yes"
    > * * * * * * * * * * * * VERSION="1.0"
    > * * * * * * * * * * * * WINDOWSTATE="maximized"/>
    > * * * * </HEAD>
    >
    > * * * * <SCRIPT Language="VBScript">
    > Dim arrUsers(1)
    >
    > ' Size window on load
    > Sub Window_onLoad
    > window.resizeTo 640, 480
    > End Sub
    >
    > ' Cancel button
    > Sub ExitProgram
    > window.close()
    > End Sub
    >
    > Sub btnComp_Click
    >
    > Set WshNetwork = CreateObject("Wscript.Network")
    > strDN = WshNetwork.UserDomain
    > arrUsers(0) = User1.value
    > arrUsers(1) = User2.value
    > For i = 0 To 1
    > *If i = 0 Then
    > * * * * * * * * * GetAllGroups(i)
    > * * * * * * * * * UserGroup1.InnerHTML = sGroups
    > *ElseIf i = 1 Then
    > * * * * * * * GetAllGroups(i)
    > * * * * * * * UserGroup2.InnerHTML = "Test 2"
    > *End If
    > *Next
    > End Sub
    >
    > Function GetAllGroups(i)
    > ' On Error Resume Next
    > Set WshNetwork = CreateObject("Wscript.Network")
    > * strDN = WshNetwork.UserDomain
    > * sUser = arrusers(i)
    > * Set objUser = GetObject("WinNT://" & strDN & "/" & sUser)
    > * For Each oGroup In objUser.Groups
    > * sGroups = sGroups & oGroup.Name & vbCrLf & "<br>"
    > * Next
    > * End Function
    >
    > * * * * </SCRIPT>
    > * * * * <body STYLE="font:10pt arial; color:white;
    > (background-color:Menu;
    > color:MenuText;
    > cursor:default">
    > * * * * <p align=left><b>Group Migration Tool</b></font></p>
    > *<table>
    > *<tr>
    > *<col align="left"></col>
    > *<col width="160"></col>
    > *<col align="left"></col>
    > *<th><b>New User ID.</b></th>
    > *<th>&nbsp;</th>
    > *<th><b>Template User ID.</b></th>
    > *</tr>
    > *<tr>
    > * <td><input type="text" name="User1" size=20><p align=left></td>
    > *<td>&nbsp;</td>
    > *<td><input type="text" name="User2" size=20><p align=left></td>
    > * *</tr>
    > * *<tr>
    > * * * * <td><input type="button" value="Compare" name="btnComp"
    > onClick="btnComp_Click" STyle='background-color: ButtonFace;'
    > STyle='color:ButtonText;'></td>
    > * * * * *<td><input id=runbutton type="button" value="Cancel"
    > onClick="ExitProgram" STyle='background-color: ButtonFace;'
    > STyle='color:ButtonText;'></td>
    > * * * * * * </tr>
    > * * * * * * *<p>
    > <td><Span ID = "DataArea"</Span></td>
    > <td><Span ID = "UserGroup1"</Span></td>
    > <td><Span ID = "UserGroup2"</Span></td>
    > </table>
    > </body>
    > </html>
    >
    > The code works in msgBox, and it writes "Test 2" in the UserGroup2
    > InnerHTML as directed, it's just not writing to the InnerHTML that
    > I've got set to populate with the variable..
    There's nothing wrong with the InnerHTML. The problem is that your
    function returns no value and Groups is not defined globally, so there
    is nothing to write. One or the other thing is needed to send the
    data back to be written. I would use the function return approach,
    myself ...

    Function GetAllGroups(i)
    ' On Error Resume Next
    Set WshNetwork = CreateObject("Wscript.Network")
    strDN = WshNetwork.UserDomain
    sUser = arrusers(i)
    Set objUser = GetObject("WinNT://" & strDN & "/" & sUser)
    For Each oGroup In objUser.Groups
    sGroups = sGroups & oGroup.Name & vbCrLf & "<br>"
    Next
    GetAllGroups = sGroups
    End Function

    Then, use the function thus ...

    Sub btnComp_Click

    ' This is useless here ... Set WshNetwork = CreateObject
    ("Wscript.Network")
    ' same here ... strDN = WshNetwork.UserDomain
    arrUsers(0) = User1.value
    arrUsers(1) = User2.value
    For i = 0 To 1
    If i = 0 Then
    UserGroup1.InnerHTML = GetAllGroups(i)
    ElseIf i = 1 Then
    ' Huh? GetAllGroups(i)
    UserGroup2.InnerHTML = "Test 2"
    End If
    Next
    End Sub

    It is clear to me that you don't understand the concept of 'scope' in
    relationship to SUBs and Functions. Basically, variables have scopes
    limited to where they are first defined in a script. If they are
    first defined at the 'MAIN' level, they are global and can be accessed
    in all subs and functions. However, if defined first in a function
    (or using a DIM statement in the routine), then they only 'exist'
    within that sub or function. Maybe you should download the WSH
    documentation and read up on this.

    WSH 5.6 documentation download (URL all one line)
    http://www.microsoft.com/downloads/d...displaylang=en

    Some of the WSH concepts don't apply to HTAs and it doesn't cover the
    HTML stuff, but it should help understand the use of functions and
    subs.

    HTH,

    Tom Lavedas
    ***********

      My System SpecsSystem Spec

  3. #3


    MattW Guest

    Re: InnerHTML not working


    Thanks, Tom, this set me in the right direction. I'll check your
    documentation out, thanks for the link.

      My System SpecsSystem Spec

InnerHTML not working

Similar Threads
Thread Thread Starter Forum Replies Last Post
My 32-bit browsers and Skype are not working online but My 64-bit browser is working hankyhat Browsers & Mail 5 05 Oct 2009
windows vista restore not working/blue screen help/safe mode not working rrr666 Vista General 4 25 Jul 2009
MS Intellipoint stopped working but ctrl panel says working proper Susan C. Vista hardware & devices 0 11 Jun 2008
Re: Right click stops working/New tabs stop working/Menu bar disappear Robert Aldwinckle Vista performance & maintenance 9 20 Nov 2007
innerHTML method not working =?Utf-8?B?QW5vbnltb3Vz?= PowerShell 3 23 Aug 2006