Results 1 to 9 of 9

Thread: Js number box. With up down buttons.

  1. #1
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Js number box. With up down buttons.

    1) Js Numeric Up Down

    2) Drew Toma

    3) This is a text bot that only allows numbers to be entered, also if it's focused and the up or down arrow are pressed it will add or subtract from the box. There are then two (removable) buttons to add or subtract from the text box.

    4) URL TO CODE:
    http://drewtoma.com/code/DynamicDriveCode
    OR
    http://drewtoma.com/?p=52

    May I say I love dynamic drive, and if there is a problem with my code please tell me what I must fix to get it uploaded here.
    Last edited by tomagig; 01-11-2011 at 02:39 AM. Reason: Link Update

  2. #2
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please hold off review I have noticed a error with my code. Sorry for the inconvenience.

  3. #3
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok so I have updated the broken code.

    The new link is: http://drewtoma.com/code/DynamicDriveCode.html.

    ChangeLog=
    Fixed up down.
    Removed using the - and + key.
    Made code run off of the text box id. To use multiple on one page.

    Again I am very sorry for the delay. If there is any other problem please tell me.

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Make it so that you can hold the + or - button and it will increase every 20 milliseconds that you're holding it for. Do something like:
    Code:
    var c;
    element.onmousedown = function() {
       c = setTimeout(function(){ el.value += 1; }, 20);
    }
    element.onmouseup = funciton(){
       clearTimeout(c);
    }
    Jeremy | jfein.net

  5. #5
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I originally had it like that but the + symbol is shift that key, and js registers the shift. But what I had was if the = was entered its the same key but different symbol.
    What was happening was it would enter the = the box, I could do a void(0). I will do that.
    Thanks,
    -tomagig

  6. #6
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I just could not get the - + keys to work. What was happening is when you focus the box and click + OR - it would enter into the box. And nothing I did would strip that or ignore it. Im sorry, but the code is ready to be reviewed.

  7. #7
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Use return: false; to get it from entering a + or - sign in the textbox (onkeypress).
    Jeremy | jfein.net

  8. #8
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Nile View Post
    Use return: false; to get it from entering a + or - sign in the textbox (onkeypress).
    That disables all functionality.

  9. #9
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Do like:
    Code:
    window.onkeypress = function(e){
    if(e.blah == 45) { //if the key == the + or - key (45 is just a place holder)
    input++;
    return false;
    }
    }
    Jeremy | jfein.net

Bookmarks

Posting Permissions

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