468,121 Members | 1,567 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,121 developers. It's quick & easy.

change textarea dynamically

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

if so is there an example ?
Nov 18 '05 #1
4 3928
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" <no****@here.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
can the rows and columns of a textarea element with an id be changed on the fly ?

if so is there an example ?

Nov 18 '05 #2
TJS
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:%2****************@TK2MSFTNGP10.phx.gbl...
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" <no****@here.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
can the rows and columns of a textarea element with an id be changed on

the
fly ?

if so is there an example ?


Nov 18 '05 #3
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" <no****@here.com> wrote in message
news:up**************@TK2MSFTNGP09.phx.gbl...
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:%2****************@TK2MSFTNGP10.phx.gbl...
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" <no****@here.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
can the rows and columns of a textarea element with an id be changed
on the
fly ?

if so is there an example ?



Nov 18 '05 #4
TJS
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:uc**************@TK2MSFTNGP09.phx.gbl...
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" <no****@here.com> wrote in message
news:up**************@TK2MSFTNGP09.phx.gbl...
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:%2****************@TK2MSFTNGP10.phx.gbl...
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" <no****@here.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> can the rows and columns of a textarea element with an id be changed on the
> fly ?
>
> if so is there an example ?
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Simon | last post: by
7 posts views Thread by Anders S. Clausen | last post: by
2 posts views Thread by Jonathan Taub | last post: by
6 posts views Thread by gilbert.george | last post: by
18 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.