change textarea dynamically

Discussion in 'ASP .Net' started by TJS, Aug 21, 2004.

  1. TJS

    TJS Guest

    can the rows and columns of a textarea element with an id be changed on the
    fly ?

    if so is there an example ?
     
    TJS, Aug 21, 2004
    #1
    1. Advertising

  2. TJS

    Karl Guest

    Using javascript, yet..what events do you want to trigger this..here's one
    that'll work on each keystroke:

    <textarea name="x" onKeyUp="SetNewSize(this);" cols="5" rows="4"></textarea>
    <script language="javascript">
    function SetNewSize(textarea){
    if (textarea.value.length > 5){
    textarea.cols = 50;
    textarea.rows = 50;
    }else{
    textarea.cols = 10;
    textarea.rows = 15;
    }
    }
    </script>

    Karl

    "TJS" <> wrote in message
    news:%...
    > can the rows and columns of a textarea element with an id be changed on

    the
    > fly ?
    >
    > if so is there an example ?
    >
    >
     
    Karl, Aug 21, 2004
    #2
    1. Advertising

  3. TJS

    TJS Guest

    with the javascript, I think I would use the onload event, but it is not
    working.


    .....
    <script language="javascript">
    function SetNewSize(textarea){
    textarea.cols = 70;
    textarea.rows = 10;
    }
    </script>

    .....
    <body onLoad="SetNewSize('DesktopText_Div_ta')">

    ....

    <textarea wrap="soft" id="DesktopText_Div_ta"
    style="width='650px';height:'100%';display:block;Background-color:#ffffff">

    ....





    "Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
    message news:%...
    > Using javascript, yet..what events do you want to trigger this..here's one
    > that'll work on each keystroke:
    >
    > <textarea name="x" onKeyUp="SetNewSize(this);" cols="5"

    rows="4"></textarea>
    > <script language="javascript">
    > function SetNewSize(textarea){
    > if (textarea.value.length > 5){
    > textarea.cols = 50;
    > textarea.rows = 50;
    > }else{
    > textarea.cols = 10;
    > textarea.rows = 15;
    > }
    > }
    > </script>
    >
    > Karl
    >
    > "TJS" <> wrote in message
    > news:%...
    > > can the rows and columns of a textarea element with an id be changed on

    > the
    > > fly ?
    > >
    > > if so is there an example ?
    > >
    > >

    >
    >
     
    TJS, Aug 21, 2004
    #3
  4. TJS

    Karl Guest

    I don't understand why you'd want to do it on load...why not just set it
    right to begin with? Well, assuming you have your reasons, you have 2
    problems with your code

    [1] you arenn't passing a reference to your textarea, you are just passing
    an id, try to change that to:
    onLoad="SetNewSize(document.getElementById('DesktopText_Div_ta'));">

    [2] Since you are using styles to set the width and height, you'll want to
    change the code to
    textarea.style.width = '900px';
    textarea.style.height = 'YYYpx';

    Karl

    "TJS" <> wrote in message
    news:...
    > with the javascript, I think I would use the onload event, but it is not
    > working.
    >
    >
    > ....
    > <script language="javascript">
    > function SetNewSize(textarea){
    > textarea.cols = 70;
    > textarea.rows = 10;
    > }
    > </script>
    >
    > ....
    > <body onLoad="SetNewSize('DesktopText_Div_ta')">
    >
    > ...
    >
    > <textarea wrap="soft" id="DesktopText_Div_ta"
    >

    style="width='650px';height:'100%';display:block;Background-color:#ffffff">
    >
    > ...
    >
    >
    >
    >
    >
    > "Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
    > message news:%...
    > > Using javascript, yet..what events do you want to trigger this..here's

    one
    > > that'll work on each keystroke:
    > >
    > > <textarea name="x" onKeyUp="SetNewSize(this);" cols="5"

    > rows="4"></textarea>
    > > <script language="javascript">
    > > function SetNewSize(textarea){
    > > if (textarea.value.length > 5){
    > > textarea.cols = 50;
    > > textarea.rows = 50;
    > > }else{
    > > textarea.cols = 10;
    > > textarea.rows = 15;
    > > }
    > > }
    > > </script>
    > >
    > > Karl
    > >
    > > "TJS" <> wrote in message
    > > news:%...
    > > > can the rows and columns of a textarea element with an id be changed

    on
    > > the
    > > > fly ?
    > > >
    > > > if so is there an example ?
    > > >
    > > >

    > >
    > >

    >
    >
     
    Karl, Aug 21, 2004
    #4
  5. TJS

    TJS Guest

    The textarea box is generated by a 3rd party assembly, so I don't have
    access to it.

    but it is working now

    thanks!


    "Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
    message news:...
    > I don't understand why you'd want to do it on load...why not just set it
    > right to begin with? Well, assuming you have your reasons, you have 2
    > problems with your code
    >
    > [1] you arenn't passing a reference to your textarea, you are just passing
    > an id, try to change that to:
    > onLoad="SetNewSize(document.getElementById('DesktopText_Div_ta'));">
    >
    > [2] Since you are using styles to set the width and height, you'll want to
    > change the code to
    > textarea.style.width = '900px';
    > textarea.style.height = 'YYYpx';
    >
    > Karl
    >
    > "TJS" <> wrote in message
    > news:...
    > > with the javascript, I think I would use the onload event, but it is

    not
    > > working.
    > >
    > >
    > > ....
    > > <script language="javascript">
    > > function SetNewSize(textarea){
    > > textarea.cols = 70;
    > > textarea.rows = 10;
    > > }
    > > </script>
    > >
    > > ....
    > > <body onLoad="SetNewSize('DesktopText_Div_ta')">
    > >
    > > ...
    > >
    > > <textarea wrap="soft" id="DesktopText_Div_ta"
    > >

    >

    style="width='650px';height:'100%';display:block;Background-color:#ffffff">
    > >
    > > ...
    > >
    > >
    > >
    > >
    > >
    > > "Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote

    in
    > > message news:%...
    > > > Using javascript, yet..what events do you want to trigger this..here's

    > one
    > > > that'll work on each keystroke:
    > > >
    > > > <textarea name="x" onKeyUp="SetNewSize(this);" cols="5"

    > > rows="4"></textarea>
    > > > <script language="javascript">
    > > > function SetNewSize(textarea){
    > > > if (textarea.value.length > 5){
    > > > textarea.cols = 50;
    > > > textarea.rows = 50;
    > > > }else{
    > > > textarea.cols = 10;
    > > > textarea.rows = 15;
    > > > }
    > > > }
    > > > </script>
    > > >
    > > > Karl
    > > >
    > > > "TJS" <> wrote in message
    > > > news:%...
    > > > > can the rows and columns of a textarea element with an id be changed

    > on
    > > > the
    > > > > fly ?
    > > > >
    > > > > if so is there an example ?
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    TJS, Aug 22, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anders S. Clausen
    Replies:
    5
    Views:
    937
    Jukka K. Korpela
    Nov 24, 2003
  2. Anders S. Clausen
    Replies:
    4
    Views:
    856
    Jukka K. Korpela
    Nov 24, 2003
  3. Augustus
    Replies:
    1
    Views:
    362
    Ken Schaefer
    Sep 10, 2003
  4. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    337
    Anthony Jones
    Feb 5, 2006
  5. Replies:
    1
    Views:
    321
    Bart Van der Donck
    Jul 4, 2007
Loading...

Share This Page