dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: textarea to innerHTML

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Posts
    1

    textarea to innerHTML

    Hello everyone!
    I have a small "problem". I'm new in Javascript. I want whatever I write in a textarea field being typed automatically in a <p> I have the script needed but
    it gets delayed -1 character. Here's the script. Paste it and tell me what's wrong

    <script type="text/javascript">
    function writeText(txt)
    {
    document.getElementById("desc").innerHTML=txt;
    }
    </script>

    <form name="form1">
    <textarea cols="45" rows="5" name="comment" onkeyPress="writeText(document.form1.comment.value)"></textarea>

    <p id="desc"></p>
    </form>


    Thanks in advance

    PS: By the way... How can I make it appear some HTML code when there characters start to be typing?

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Instead of using onKeyPress, use onKeyUp or onChange.

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles