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 BatCountry's Avatar
    Join Date
    Jul 2007
    Location
    McMaynerberry, Texas
    Posts
    57
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Exclamation Interacting with a TextArea?

    Is it possible to interact with a textarea field:
    Code:
    <textarea id="list"></textarea>
    I have a textarea where you can enter one item per a line, and I want to be able to get each new line in the textarea. I can't find any way with the DOM to get how many rows are in the textarea and how to know what is each row.

    Anyone give a hand?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,854
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    I hope you are trying to get something like
    Drop menu to add text to textarea
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I guess you were looking for an end line separator ('\n')
    Something like this?:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    function alertLine(f){
    var n=Number(f['nr'].value)-1, t=f['txa'].value.split('\n');
    if(t[n]){alert(t[n])}
    }
    </script>
    </head>
    <body>
    <form action="">
    <textarea name="txa" id="txa"></textarea>
    <br><br>
    <input type="button" value="Alert the line no:" onclick="alertLine(this.form)"> <input type="text" name="nr" id="nr" size="4">
    </form>
    </body>
    </html>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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