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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reload event after 4 digits entered - HELP!

    Hey,
    I am currently using onkeyup for the page to reload but what i need is for the user to enter in 4 digits before the onkeyup function kicks in.

    How can i do this??? It is for a postcode field which reloads a suburbs drop list.

    Code:
    echo "Postcode: <input name='cat' type=text onkeyup=\"reload(this.form)\" value=$cat>";
    
    //I need it to reload after 4 digits have been entered.
    Thanks

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    This maybe?
    PHP Code:
    echo "Postcode: <input name='cat' type=text onkeyup=\"i++if(i == 4)reload(this.form)\" value=$cat>"

  • #3
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    That's erroneous ninnypants.

    Try this instead:
    PHP Code:
    echo "Postcode: <input name='cat' type=text onkeyup=\"if(this.value.length>4)reload(this.form);else return false;\" value=$cat>"
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #4
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry just remembered that Australian post codes are 3 to 4 digits long.
    I will have to just add a button which reloads the suburbs in the drop list.

    Or if i 4 digits are entered it is reloaded and the button dissapears but if 3 digits then the button stays and user presses it manualy.
    Can i do that? Because there are only about 11 suburbs with the 3 digits.
    Last edited by BillyMako; 08-07-2008 at 04:44 AM.


  •  

    Posting Permissions

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