www.webdeveloper.com
Results 1 to 3 of 3

Thread: Get current input value and add or subtract 1 to generate the new input value?

  1. #1
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    265

    Question Get current input value and add or subtract 1 to generate the new input value?

    I've got something like this...

    Code:
    document.getElementById('bump23id').value= (?)
    ...for a button.

    There is an input field (a text field) with the name/id "bump23id".

    When someone clicks the button, I want the "bump23id" field to go up one number (like if it's already at 3, it will go to 4)

    I also want to create a second button just like the first that will make it go down one number.

    How do I make it get the current value of the input field and then add or subtract 1 from the number to create the new value?

  2. #2
    Join Date
    Nov 2010
    Posts
    1,097
    Code:
    <input type="button" value="up" onclick="Number(document.getElementById('bump23id').value++)" >

  3. #3
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    265
    Thanks!

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