473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 4206
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Simon | last post by:
I have another question.. Let's take a textarea with the parameter: "rows=4" (<textarea rows=4 onkeydown="CheckScrollbar()"> ) If you start typing the scrollbar at the right is not active. Only...
7
by: Anders S. Clausen | last post by:
Hi I have a jsp with a couple of <HTML:TEXTAREA> where I would like to dynamically size the textarea depending on the length of a String entered on a different jsp. The two new textareas are to...
4
by: dekern | last post by:
I have been trying to set the default text value of a TextArea element for about a day now without any luck. Similar to the code used to set the Text field below I would like to use the returned...
2
by: Jonathan Taub | last post by:
This may seem a stupid question. I've got a <textarea> element: .... <td> List of items: <textarea> 1. Apple 2. Orange 3. Box
3
by: Jarek Mielcarek | last post by:
hi all, in xml file I have some fields which are source for <textarea> element. I'd like to transform this file using xslt and set the rows property of <textarea> depend of lines in some source...
3
by: zjw2112 | last post by:
Hello. I have some javascript code that dynamically creates a textarea and sets the wrap value to hard, which I thought would preserve CR/LF in the textarea: var otherTextArea =...
2
by: Daz | last post by:
Hi all. I am trying to find a way of making a textarea fit into the surrounding table cell which is dynamically created. As far as I know, I can only use cols and rows to tell the parser what...
6
by: gilbert.george | last post by:
Hi, I am setting the width of a textarea using the style.width to ensure the textarea is exactly the right width. I want to set the height/rows of the textarea depending on it's contents (so...
1
by: chrisdr | last post by:
I found this code in a previous post but I am not able to get this to work for me... I am trying to dynamically change an element's type from textbox to textarea with an event. Actually in my code...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.