Jump to content

vAriable Scope


george

Recommended Posts

Basically I have this

<html><head><script type="text/javascript"> <!--   var iterator = 1;function calculate() {	iterator++;}   --></script></head><body><form><input type="button" onclick="calculate();" value="Press Me"  /></form></body></html>

I want to be able to increment the variable "iterator" each time I click "Press Me".

Link to comment
Share on other sites

Unless i'm missing something here your code is fine :) If you put an alert in the function you will see the value incrementingfunction calculate() { alert(iterator); iterator++;}Hope this helps :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...