How to call a VBScript function from button "on click"

I've got the following code trying to call a function and pass variables to the function, but I get the message that I cannot use parantheses while calling a sub....

I'm not calling a sub though....
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css"
href="\\server\path\CSS.css"/>
<TITLE>Profile Cleanup Utility</TITLE>
<HTA:APPLICATION 
     APPLICATIONNAME="Program"
     SCROLL="no"
     BORDER="THIN"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     MINIMIZEBUTTON="no"
     MAXIMIZEBUTTON="no"
     ICON="\\server\path\icon.ico"
>
 
<script language="VBScript">
 
'=====================
'Defining variables
'=====================
Const ForReading = 1
const ForWriting = 2
Const ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
 
strDate = Date()
intDel = 60
 
strTotalSize = 0
strMonth = Month(Now)
strDay = Day(Now)
strYear = Year(Now)
 
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
'================================
'Determine location to run script
'================================    
    Sub RunLocation
	
		strLocation = SelectLocation.Value
		select case strLocation
			case ""
				GroupSelect.innerHTML = ""
				
			case "Boise"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='BoiseSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='PPD'>PPD</option>" &_
					"<option value='WDTS'>WDTS</option>" &_
					"<option value='TRN'>TRN</option></select>"
	
		End Select
	
	End Sub
	
	Sub BoiseSetGroupInfo
		
		strGroup = SelectGroup.Value
				
				select case strGroup
				
					case ""
					'nothing
					case "PPD"
						Offline = "\\server\path\file.txt"
						Deleted = "\\server\path\file.txt"
						Checked = "\\server\path\file.txt"
						strExcelPath = "\\server\path\file.txt"
						strMachineGroup = "PPD*"
						strGroupLocation = "LDAP://ou=path,ou=path,ou=path,dc=dc,dc=domain,dc=com"
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup(Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation)'>"								End Select		
	End Sub
	
	Function ProcessGroup(Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation)
		
		objCommand.CommandText = "SELECT Name, dNSHostName FROM '" & strGroupLocation & "' WHERE objectCategory='computer' AND dNSHostName='" & strMachineGroup & "'"
		Set objRecordSet = objCommand.Execute
		
		objRecordSet.MoveFirst
		
		Do Until objRecordSet.EOF
			strComputer = objRecordSet.Fields("Name").Value
			msgbox(strcomputer)
			objRecordSet.MoveNext
		Loop
		
		msgbox("Action Complete")
	End Function
	
</script>
 
</HEAD>
<BODY>
<DIV id="Background_DIV">
<img src= "\\server\path\image.bmp" height=100% width=100%/>
<script type="text/javascript">
	{
	window.resizeTo(400,300)
	window.moveTo(0,0);
	}	
</script>
 
<DIV id="LocationSelect_DIV">
<select size="1" width="30" name="SelectLocation" onchange="RunLocation">
    <option selected value="">Make a Selection</option>
    <option value="Boise">Boise</option>
    <option value="Seattle">Seattle</option>
</select>
</DIV>
 
<DIV id="GroupSelect_DIV" align="Center">
<span id="GroupSelect"></span>
</DIV>
<DIV id="ActionButton_DIV" align="Center">
<span id="StartAction"></span>
</DIV>
<DIV id="Status_DIV">
<span id="CurrentStatus"></span>
</DIV>
</DIV>
</BODY>
</HTML>

Open in new window

LVL 12
piattndAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rejoinderCommented:
The function call should not have parenthesis when you use multiple variables.  Use the following in your code and all should work fine (at least for me it did);
StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation'>"
0
VallerianiCommented:
Try using:

                                                StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='Call ProcessGroup(Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation)'>"


(Add Call infront of it)
0
piattndAuthor Commented:
I've tried using call and it doesn't work.

I also rtied what you said, rejoinder, and I don't get a script error,  but the echo returns a null value for any of my variables.  In other words, the values aren't being passed.
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

piattndAuthor Commented:
Ok so I talked to my scripting buddy and he said I should change the "onclick" portion to something similar to this:

<....onclick= FunctionName '" & variablename & "'>

I was able to get it to work for one of my variables, then tried to do the same thing for all of them, and now I consistently get the error:

"Wrong number of arguments or invalid property assignment"

Keep in mind I have adjusted my Function to reflect that I'm only trying to pass 1 variable for the time being (until I get the dang thing to work with 1 variable).

Thoughts?
0
rejoinderCommented:
I know why my method returned null... please use this line instead;
StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """'>"

Drop the () and use double quotes plus ampersand to get your variables into the line.  So easy I forgot that you were passing variables from above :-)

I tested this by using a msgbox in the function and I was able to see all the variables being passed.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
piattndAuthor Commented:
Holy cow, thank you so much!  I was literally bashing my head on my desk all morning......
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.