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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript count increment on buton click

Status
Not open for further replies.

woter324

Technical User
Jan 26, 2007
179
GB
Hi,

I am trying to create a function that will increment an integer by 1 each time a button in an HTA is pressed. I can get it to count to 1, but no further. I am sure it's simple, but I cannot see the wood for the trees.


Below is my code. There is an onClick event called from the HTML page that take an argument of either 'up' or 'down' and this counts up or down.


Code:
Function buttonCount(direction) 
  If direction = "up" Then
	var = var+1
	DataArea.InnerHTML=var 
  ElseIf direction = "down" Then
	var = var-1
	DataArea.InnerHTML=var  
  End If
End Function

Any help would be grately apreciated as always.

Many thanks

Woter.
 
are your variables global or local. if they are local to the function, they are no longer available when processing leaves the function...
 
[tt]<script language="vbscript">
[red]dim var 'add this declaration[/red]
Function buttonCount(direction)
'etc etc
End Function
'etc etc
</script>[/tt]
 
Ahhh!

Thanks very much. I knew the wood was there somewhere :)

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top