george Posted October 11, 2007 Share Posted October 11, 2007 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 More sharing options...
scott100 Posted October 11, 2007 Share Posted October 11, 2007 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 More sharing options...
chrisciscoioio Posted October 11, 2007 Share Posted October 11, 2007 What you have there will work fine, no need to change that. Link to comment Share on other sites More sharing options...
george Posted October 12, 2007 Author Share Posted October 12, 2007 You all are right. Thanks for looking. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.