Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBscript and Javascript in the same HTA Application not working...

Status
Not open for further replies.

cbsarge

IS-IT--Management
Jun 20, 2001
219
0
0
US
I have the following HTA application. This is a small version of a larger one I'de like to use to wrap a bunch of VBscripts for AD, hardware, processes, etc. I want to be able to use checkboxes to expand areas of the HTA when I want to use those types of tools.

Code:
<html>
<head>
<title>Useful Tools</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Useful Tools"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<script language="JScript">
function HidePart(d) { document.getElementById(d).style.display = "none";  }
function ShowPart(d) { document.getElementById(d).style.display = "block"; }
function CheckboxChecked(b,d)
{
   if(b) { ShowPart(d); }
   else  { HidePart(d); }
}
</script>
<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 1024,900
    End Sub 
</script>
</head>
<body>
<h1>Useful Tools</h1>
<form>
<p>
<input type="checkbox" name="mycheckbox" value="yes" onclick="CheckboxChecked(this.checked,'checkboxdiv4')">
Check this box to see Process Tools.
</p>
<div id="checkboxdiv4" style="display:none">
<p>
<input type="button" value="Process Information" name="run_button"  onClick="ProcessInfo"><p>
</p>
</div>
</form>
</body>
</html>
The expanding by a checkbox works but, the script causes an error. When I run this same script in an HTA that doesn't use a Javascript (for the expanding checkbox) it works fine.

Can anyone tell me what's wrong?

Thanks!

[!]The AutoSavers![/!] [2thumbsup]
 
Thanks for the reply!

I added the code as you recommended but, still doesn't work. I get an "object doesn't support this property or method" when I click on the button to launch the vbscript.

Here is the current non-working code:
Code:
<html>
<head>
<title>Useful Tools</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Useful Tools"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
     VERSION="1.0"
/>
<script language="javascript" type="text/javascript">
function HidePart(d) { document.getElementById(d).style.display = "none";  }
function ShowPart(d) { document.getElementById(d).style.display = "block"; }
function CheckboxChecked(b,d)
{
   if(b) { ShowPart(d); }
   else  { HidePart(d); }
}
</script>
<script language="VBScript">
On Error Resume Next
	Sub ProcessInfo
Dim strComputer
strComputer = InputBox("Enter the name of the Computer:")
Dim strProcess
strProcess = InputBox("Enter the name of the Process to search for:")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '" & strProcess & "'")
For Each oItem in colItems
	MsgBox "Process Name: " & oItem.Caption
	MsgBox "Windows Version: " & oItem.WindowsVersion
    MsgBox "Creation Class Name: " & oItem.CreationClassName
    MsgBox "Creation Date: " & oItem.CreationDate
    MsgBox "Executable Path: " & oItem.ExecutablePath
    MsgBox "Execution State: " & oItem.ExecutionState
    MsgBox "Install Date: " & oItem.InstallDate
    MsgBox "Page Faults: " & oItem.PageFaults
    MsgBox "Page File Usage: " & FormatNumber(oItem.PageFileUsage/1048576, 2) & "MB"
    MsgBox "Peak PageFile Usage: " & FormatNumber(oItem.PeakPageFileUsage/1048576, 2) & "MB"
    MsgBox "Peak Virtual Size: " & FormatNumber(oItem.PeakVirtualSize/1048576, 2) & "MB"
    MsgBox "Peak Working Set Size: " & FormatNumber(oItem.PeakWorkingSetSize/1048576, 2) & "MB"
    MsgBox "Status: " & oItem.Status
Next
		End Sub
		</script>
<script language="VBScript">
    Sub Window_onLoad
        window.resizeTo 1024,900
    End Sub 
</script>
</head>
<body>
<h1>Useful Tools</h1>
<form>
<p>
<input 
   type="checkbox" name="mycheckbox" value="yes" onclick="CheckboxChecked(this.checked,'checkboxdiv4')">
Check this box if you are married.
</p>
<div id="checkboxdiv4" style="display:none">
<p>
<input type="button" value="Process Information" name="run_button" onClick="ProcessInfo"><p>
</p>
</div>
</form>
</body>
</html>

[!]The AutoSavers![/!] [2thumbsup]
 
Comment out the On Error Resume Next and see if that will let you know which property or method reference is making your code choke.

Lee
 
O.K. - I figured it out myself but, figured I'd post the solution in case anyone else stumbles across this thread.

I changed the line:
Code:
Sub Processinfo

to:
Code:
Sub Processinfo_OnClick

and then changed the code that fires off the script to:

Code:
<input name="ProcessInfo" type="button" value="Process Information">

and that worked.

Thanks to all who tried to help!



[!]The AutoSavers![/!] [2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top