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 to the CF scene
    Join Date
    May 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Html adding text to textbox

    Hello, I would like to know how to type one thing in a textbox1 and have it appear in textbox2, but not replacing the text in textbox2, but adding new text at the end of the string of text. That might so confusing. Basically typing something in a text box and having it show up a the end of another textbox's text string. I'm very new to html and trying to get thing to work. I really have no starting code. I'm clueless, so anything you guys know helps. Thanks.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,459
    Thanks
    0
    Thanked 632 Times in 622 Posts
    You can't do that using HTML. You will need to use JavaScript to do that.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Aug 2012
    Posts
    116
    Thanks
    0
    Thanked 25 Times in 25 Posts
    Here is a very simple javascipt that may help you with you're looking for:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript">
    function test(){
    var x = document.getElementById('one');
    var y = document.getElementById('two').value;
    x.value+=" "+y;
    }
    </script>
    </head>
    <body>
    <textarea id="one">Box One</textarea>
    <textarea id="two">Box Two</textarea></br>
    <button type="button" onclick="test()">Add</button>
    </body>
    </html>
    Hope this helps
    1 Corinthians 15:3-4 / Ephesians 2:8-9 - What or Who are you living for?


  •  

    Posting Permissions

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