www.webdeveloper.com
Results 1 to 2 of 2

Thread: Counter/Button

  1. #1
    Join Date
    Feb 2004
    Posts
    7

    Counter/Button

    I was wondering if you can help me with a problem.

    Here is the code for a button:

    TD bgColor=silver><INPUT onclick=Calculate() type=button value=Calculate name=But1></INPUT>

    How can I add another command to count the number of times the button
    was clicked?

    I want to display on the bottom of the page "Total number of
    calculations: ???"

    How can I make it count and display?

    Thank you,

  2. #2
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    Code:
    <script type="text/javascript">
    //<![CDATA[
    	var i = 0;
    //]]>
    </script>
    Code:
    <form action="#">
    	<div>
    		<input type="button" value="foo" onclick="document.getElementById('out').firstChild.nodeValue = 'Number of calculations: ' + (i++);" />
    	</div>
    	<div id="out">&amp;nbsp;</div>
    </form>
    Last edited by fredmv; 02-19-2004 at 03:43 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles