SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    0 Post(s)
    0 Thread(s)

    try to write a script that adds 1 value to a variable everytime a button is clicked


    I am new to javascript. I was trying to do something rather basic. I want to creat a button that when clicked, it will increase the value of a variable by 1. And then if the variable = 1, it will write a= 1 and redirect to a url.

    here's my script, can anyone tell me where I went wrong?

    HTML Code:
    <script type="text/javascript">
    var a=0
    function addToa() {
    	 a=(a + 1)
    if(a==1) {
    <div style=" position: absolute; left:80; top: 35;">
    <input type="button" onclick="addToa()" value="Next">
    Last edited by Mittineague; Aug 11, 2011 at 10:23. Reason: reformatting bbcode tags


Posting Permissions

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