[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

InnertHTML Issue with recognizing tags

Posted on 2009-05-05
4
Medium Priority
?
331 Views
Last Modified: 2012-05-06
Hi guys,
I have an issue with tr and td tags not being recognized.The following code does not seem to recognize the tr and td tags, so im not quite getting the formatting in a table properly.
Im not sure if this is because of the way the Results.InnerHTML is set?
Any help greatly appreciated.
<head>
<title>Enumerate Service Pack on Remote Computers</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Enumerate Service Pack on Remote Computers"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
<style type="text/css">
 
html {
font-family:arial;
font-size:smaller;
 
}
 
table {
border-collapse:collapse;
border:solid 1px black;
font-family:arial;
font-size:0.8em;
}
 
tr, td, th {
border-collapse:collapse;
border-style:solid;
}
 
td { border-width: 1px; }
 
 
</style>
 
 
</head>
<script language="vbscript">
Sub Window_onLoad
	intWidth = 600
	intHeight = 480
	Me.ResizeTo intWidth, intHeight
    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
End Sub
 
Sub GetServicePack
	run_button.disabled = True
	ComputerListFile.disabled = True
	Const ForReading = 1
	Const ForWriting = 2
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	If ComputerListFile.Value <> "" Then
		If objFSO.FileExists(ComputerListFile.Value) = True Then
			Set List = objFSO.OpenTextFile(ComputerListFile.Value, ForReading)
			
			Results.InnerHTML = ""
			Results.InnerHTML = Results.InnerHTML &"<table width='40%' border=1 bgcolor='white'><th style='background:c0c0c0'>" & "<b>System</b>" & "</th><th style='background:c0c0c0'>" & _
			"<b>Service Pack</b>"
 
			Do Until List.AtEndOfStream
				strComputer = List.ReadLine
				If Ping(strComputer) Then
 
					Set objWMIService = GetObject("winmgmts:" _
					& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
					Set colSpack = objWMIService.ExecQuery _
					("Select * from Win32_OperatingSystem")
					For Each objSpack in colSpack
						strSpack = objSpack.ServicePackMajorVersion
					Next
 
					Results.InnerHTML =  Results.InnerHTML &"<tr><td width='40%' border=1>" &strComputer &"</td><td>" &strSpack &"</td></tr><br>"
 
					'Results.InnerHTML =  Results.InnerHTML & "<tr><td>" & strComputer & "</td><td>" & strSpack & "</td></tr>"
 
				Else
 
					Results.InnerHTML =  Results.InnerHTML &"<tr><td>"& strComputer & "</td><td style='background:black'><font color='red'>Unreachable</font></td></tr><br>"
					
				End If
			Loop
Results.InnerHTML =  Results.InnerHTML &"</table>"
			List.Close	
			
			'Results.InnerHTML =  Results.InnerHTML &"</table>"
		Else
			MsgBox "File does not exist: " & ComputerListFile.Value
		End If
	Else
		MsgBox "Please specify a file name."
	End If
	run_button.disabled = False
	ComputerListFile.disabled = False
 
End Sub
	
Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function
 
</script>
 
<body>
<input type="button" value="Get Service Pack" name="run_button" onClick="GetServicePack">
<input type="file" name="ComputerListFile"> <br><br>
<span id = "Results"></span>
</body>
</html>

Open in new window

0
Comment
Question by:Simon336697
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 14

Expert Comment

by:rejoinder
ID: 24308213
Please give this a try...
<head>
<title>Enumerate Service Pack on Remote Computers</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Enumerate Service Pack on Remote Computers"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>
<script language="vbscript">
Sub Window_onLoad
    intWidth = 600
    intHeight = 480
    Me.ResizeTo intWidth, intHeight
    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
End Sub
 
Sub GetServicePack
    run_button.disabled = True
    ComputerListFile.disabled = True
    Const ForReading = 1
    Const ForWriting = 2
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If ComputerListFile.Value <> "" Then
        If objFSO.FileExists(ComputerListFile.Value) = True Then
            Set List = objFSO.OpenTextFile(ComputerListFile.Value, ForReading)
            strHTML = "<table width=40% border=1 bgcolor=""white""><tr><td style=""background:c0c0c0""><b>System</b></td><td style=""background:c0c0c0""><b>Service Pack</b></td></tr>"
            Do Until List.AtEndOfStream
                strComputer = List.ReadLine
                If Ping(strComputer) Then
                    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
                    Set colSpack = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
                    For Each objSpack in colSpack
                        strSpack = objSpack.ServicePackMajorVersion
                    Next
                    strHTML = strHTML & "<tr><td>" & strComputer & "</td><td>" & strSpack & "</td></tr>"
                Else
                    strHTML = strHTML & "<tr><td>" & strComputer & "</td><td style=""background:black""><font color=""red"">Unreachable</font></td></tr>"
                End If
            Loop
            Results.InnerHTML = strHTML &"</table>"
msgbox Results.InnerHTML
            List.Close
        Else
            MsgBox "File does not exist: " & ComputerListFile.Value
        End If
    Else
        MsgBox "Please specify a file name."
    End If
    run_button.disabled = False
    ComputerListFile.disabled = False
End Sub
	
Function Ping(strComputer)
    Dim objShell, boolCode
    Set objShell = CreateObject("WScript.Shell")
    boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
    If boolCode = 0 Then
        Ping = True
    Else
        Ping = False
    End If
End Function
 
</script>
 
<style type="text/css">
html {font-family:arial;font-size:smaller;}
table {border-collapse:collapse;border:solid 1px black;font-family:arial;font-size:0.8em;}
tr, td, th {border-collapse:collapse;border-style:solid;}
td { border-width: 1px; }
</style>
<body>
<input type="button" value="Get Service Pack" name="run_button" onClick="GetServicePack">
<input type="file" name="ComputerListFile"> <br><br>
<span id="Results" name="Results"></span>
</body>
</html>

Open in new window

0
 
LVL 14

Accepted Solution

by:
rejoinder earned 2000 total points
ID: 24308227
Please remove line 42;
msgbox Results.InnerHTML
I was using that to test some things out.
0
 
LVL 1

Author Comment

by:Simon336697
ID: 24322280
thanks so much rejoinder.
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 24322316
Glad to help out and thanks for the points :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question