SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast vertlime's Avatar
    Join Date
    Nov 2004
    Location
    UK, Canada
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    auto-tabbing - need help

    I have a form that has 3 inputs for the phone number (XXX) - (XXX) - (XXXX)

    how can I get the number boxes to work so that as the
    user is putting in their number is automatically goes to the next box? For
    example, when I put in my area code "909" I have to TAB or click into the
    next box. How can I make it so it automatically goes to the next box?

    please make is simple as I am novice

    Thank you!
    Innovative Graphic Design Solutions
    www.magentismedia.com



  2. #2
    SitePoint Enthusiast vertlime's Avatar
    Join Date
    Nov 2004
    Location
    UK, Canada
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind

    I found it.

    Innovative Graphic Design Solutions
    www.magentismedia.com



  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Let's say you have this:
    HTML Code:
    <div id="phone">
      <input type="text" name="phone1" maxlength="3">
      <input type="text" name="phone2" maxlength="5">
      <input type="text" name="phone3" maxlength="5">
    </div>
    Then you put this in an external javascript file:
    Code Javascript:
    function init() {
      var phonebits = document.getElementById('phone').getElementsByTagName('input');
      phonebits[0].onkeypress = moveNext;
      phonebits[1].onkeypress = moveNext;
    }
    function moveNext() {
      if(this.value.length < 3) return;
      else this.nextSibling.nextSibling.focus();
    }
    window.onload = init;

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ah.

  5. #5
    SitePoint Enthusiast vertlime's Avatar
    Join Date
    Nov 2004
    Location
    UK, Canada
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much Raffles.
    Innovative Graphic Design Solutions
    www.magentismedia.com




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
  •