HighDots Forums  

Re: Increase displayed variable after clicking button

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Increase displayed variable after clicking button in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Daniel Kirsch
 
Posts: n/a

Default Re: Increase displayed variable after clicking button - 07-04-2005 , 07:08 AM






Zeljko wrote:
Quote:
I would like to make a page with only one button and one variable that
is displayed.
javascript:
var myNumber = 0; // better don't use number as your variable's name.
function add() {
myNumber++;
document.getElementById("variableVal").innerHTML = myNumber;
}


HTML:
<body>
<div id="variableVal">0</div>
<input type="button" onclick="add()" value="+">'
</body>

Daniel


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.