Tuesday, October 3, 2023
 Popular · Latest · Hot · Upcoming
38
rated 0 times [  45] [ 7]  / answers: 1 / hits: 133462  / 15 Years ago, fri, may 8, 2009, 12:00:00

Can I create a javascript variable and increment that variable when I press a button (not submit the form).
Thanks!


More From » javascript

 Answers
86

Yes:



<script type=text/javascript>
var counter = 0;
</script>


and



<button onclick=counter++>Increment</button>

[#99576] Sunday, May 3, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
martina

Total Points: 101
Total Questions: 103
Total Answers: 111

Location: Seychelles
Member since Mon, Jun 28, 2021
2 Years ago
;