Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > change textarea dynamically

Reply
Thread Tools

change textarea dynamically

 
 
TJS
Guest
Posts: n/a
 
      08-21-2004
can the rows and columns of a textarea element with an id be changed on the
fly ?

if so is there an example ?


 
Reply With Quote
 
 
 
 
Karl
Guest
Posts: n/a
 
      08-21-2004
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 ?
>
>



 
Reply With Quote
 
 
 
 
TJS
Guest
Posts: n/a
 
      08-21-2004
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;B ackground-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 ?
> >
> >

>
>



 
Reply With Quote
 
Karl
Guest
Posts: n/a
 
      08-21-2004
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('Deskto pText_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;B ackground-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 ?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
TJS
Guest
Posts: n/a
 
      08-22-2004
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('Deskto pText_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;B ackground-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 ?
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add </textarea> within <textarea> tags? frank.moens@gmail.com Javascript 1 07-04-2007 04:00 PM
Textarea Inside of a textarea wperry1@gmail.com ASP General 6 02-05-2006 08:00 AM
How do I dynamically size a <HTML:TEXTAREA>???? Anders S. Clausen Java 5 11-24-2003 07:56 AM
How do I dynamically size a <HTML:TEXTAREA>???? Anders S. Clausen HTML 4 11-24-2003 07:56 AM
Removing carriage returns from <textarea></textarea> input Augustus ASP General 1 09-10-2003 04:55 AM



Advertisments