How to manipulate input text!?

Discussion in 'HTML & Website Design' started by Peaches54s, May 7, 2007.

  1. #1
    Hi, im pretty new to javascript and was wondering how it would be possible to create a form that allows users to enter their first and last name and then when the submit button is clicked to manipulate the results to look like this

    example:

    First name = John
    Last name = Smith

    Results show jsmith
     
    Peaches54s, May 7, 2007 IP
  2. kkoder2007

    kkoder2007 Peon

    Messages:
    172
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <html>
    <head>
    <title>example</title>
    <script language="javascript">
    function alertName()
    {
    var fname=document.getElementById("firstname").value.charAt(0);
    var lname=document.getElementById("lastname").value;
    alert(fname.toLowerCase()+lname.toLowerCase());
    }
    </script>
    </head>
    
    <body>
    First Name:<input id="firstname" name="firstname" type="text" />
    Last Name:<input id=="lastname" name="lastname" type="text" />
    <input type="button" value="click me" onClick="alertName()" />
    </body>
    </html>
    
    HTML:
    hope this helps.
     
    kkoder2007, May 7, 2007 IP