Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Button to increase or decrease var speed

    I'm trying to create a button that will increase and decrease the var speed variable

    ex:

    Code:
    var speed = 5
    
    <input onclick="??????" type="button" value="Increase Var Speed">
    <input onclick="??????" type="button" value="Decrease Var Speed">
    Help, anyone?
    Last edited by exocintact; 07-28-2009 at 02:53 AM.

  • #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    try this:
    Code:
    <input onclick="increase()" type="button" value="Increase Var Speed">
    <input onclick="decrease()" type="button" value="Decrease Var Speed">
    in your js code:
    Code:
    function increase()
    {
      speed  = Number(speed ) + 1;
    }
    
    function decrease()
    {
      speed  = Number(speed ) - 1;
    }

  • Users who have thanked ckeyrouz for this post:

    exocintact (07-28-2009)

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    it worked!

    Thanks very much!!


  •  

    Posting Permissions

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