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
    Aug 2009
    Location
    public_html/cgi-bin/
    Posts
    91
    Thanks
    14
    Thanked 1 Time in 1 Post

    Question Showing letters in form

    Hey everyone

    Okay so...
    I'm working on a site, which will include a registration form for users that wish to register. In this registration form I would like it to have an AJAX based effect, such that when the user types each letter out for his username in the field, his username will appear (letter upon letter) itself below, at the end of their unique url.

    To explain further:-
    Say I type my username to be Owen
    Below the field I would like it to display:
    http://www.mydomain.com/Owen
    http://Owen.mydomain.com/
    As I type it. Is this possible?

    I've done my research, but had little luck. I'm sure it is possible as I've seen it before in a slightly different manner.

    Hope you can or are willing to help

    Thank you
    Owen Ayres

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,232
    Thanks
    80
    Thanked 4,456 Times in 4,421 Posts
    Very very simple:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function updateURLs(nm)
    {
        document.getElementById("url1").innerHTML = "http://www.mydomain.com/" + nm;
        document.getElementById("url2").innerHTML = "http://" + nm + ".mydomain.com";
    }   
    </script>
    </head>
    <body>
    <form>
    Enter your name: <input name="myname" onkeyup="updateURLs(this.value)">
    <br/><br/>
    url1: <span id="url1">http://www.mydomain.com/</span>
    <br/>
    url2: <span id="url2">http://.mydomain.com</span>
    </form>
    </body>
    </html>
    If you wanted the URLs to be in form fields instead, that's a trivial change.

  • #3
    New Coder
    Join Date
    Aug 2009
    Location
    public_html/cgi-bin/
    Posts
    91
    Thanks
    14
    Thanked 1 Time in 1 Post
    That's the bad boy I want
    Thanks for the help and speedy response Old Pedant!
    Last edited by Owener94; 07-27-2011 at 09:41 PM.


  •  

    Posting Permissions

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