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 Coder
    Join Date
    Jun 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    auto enter text based on text in another field

    Hi,

    I'm hoping this will be an easy one for you experts out there.

    I am working on a convention registration form.

    What I'm trying to do is have the text "50.00" pop into the COST field when any text (even if it's only one character) is entered into the NAME field.

    If the text in the NAME field is deleted, the "50.00" should also be deleted.

    Does anyone have a script that does this?

    Thanks!

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    like this?
    Code:
    <body>
    name: <input type="text" onkeyup="checkName(this.value)"/> 
    cost: <input type="text" id="cost"/> 
    <script type="text/javascript">
    function checkName(name){
    document.getElementById("cost").value=name?"$50.00":"";
    }
    </script>
    </body>

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    GENIUS!!!!

    Thank you - it works like a charm


  •  

    Posting Permissions

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