Results 1 to 2 of 2

Thread: Dynamic text wrap around TextArea

  1. #1
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamic text wrap around TextArea

    Hi,

    I can successfully create a textarea which increase in height as you type into it.

    However, I have some textarea's which are populated with text from a database table field from SQL Server 2005.

    When I try and wrap the textarea around text pulled from my database it doesn't do it. You still have to scroll down to read the text.

    Is there any way the textarea can just wrap itself around the text which it pulls from the database?

    My code currently looks like this:-

    In the head section I have the following code::-

    Code:
    <script>
    function sz(t) {
    a = t.value.split('\n');
    b=1;
    for (x=0;x < a.length; x++) {
     if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
     }
    b+= a.length;
    if (b > t.rows) t.rows = b;
    }
    </SCRIPT>
    In the main body I have the code:-

    Code:
    <textarea onkeyup="sz(this);" rows="40" cols="80" name="appreview" id="appreview" value="<%=objRS("review")%>"></textarea>
    Thanks.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <script type="text/javascript">
    function sz(t){
    var a = t.value.split('\n'), b = a.length;
    for (var x = 0; x < a.length; ++x)
      if (a[x].length >= t.cols) b += Math.floor(a[x].length/t.cols);
    if (++b > t.rows) t.rows = b;
    };
    window.onload = function(){sz(document.getElementById('appreview'));};
    </script>
    Last edited by jscheuer1; 09-10-2008 at 10:51 AM. Reason: formatting
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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