Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > How do I dynamically size a <HTML:TEXTAREA>????

Reply
Thread Tools

How do I dynamically size a <HTML:TEXTAREA>????

 
 
Anders S. Clausen
Guest
Posts: n/a
 
      11-22-2003
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 display the full text (and no
scroll bars), and I was wondering what I set the row and cols to ....
keeping in mind that I have the length of the text I want to display.
Any ideas???

Cheers.

Anders


 
Reply With Quote
 
 
 
 
Toby A Inkster
Guest
Posts: n/a
 
      11-22-2003
Anders S. Clausen wrote:

> he two new textareas are to display the full text (and no
> scroll bars), and I was wondering what I set the row and cols to ....


Wouldn't <pre> make more sense than <textarea>?

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

 
Reply With Quote
 
 
 
 
Bertilo Wennergren
Guest
Posts: n/a
 
      11-22-2003
Anders S. Clausen wrote:

> 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 display the full text (and no
> scroll bars), and I was wondering what I set the row and cols to ....
> keeping in mind that I have the length of the text I want to display.


You don't really have the lenght of the text, if you mean the width and
height it will take to display it, since you can't know what font and
font size will be used. If you're lucky, a fixed width font will be
used, which makes it easier, be you can't count on that.

--
Bertilo Wennergren <(E-Mail Removed)> <http://www.bertilow.com>

 
Reply With Quote
 
Matthias H. Risse
Guest
Posts: n/a
 
      11-23-2003
hi,
simply access the style-elements you usually
set statically in your css.

/* resize specific textfield */
function resizeElement(x,y)
{
document.formName.elementName.style.height = y;
document.formName.elementName.style.width = x;
}


this would be more elegant / flexible, but is untested:

/*
* @param id id of to be modified element
* @param x new width in pixel
* @param y new height in pixel
*/
function resizeElement(id,x,y)
{
var a = 30;
var b = 30;

document.getElementById(id).style.height = y-a;
document.getElementById(id).style.width = x-b;
}

you could e.g. call this in <body> tag on events onLoad and/or
onResize, depending on your needs. remember to give your textarea
an id="foo" attriute for this one.

yours
matthias

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      11-24-2003
Toby A Inkster <(E-Mail Removed)> wrote:

>> he two new textareas are to display the full text (and no scroll
>> bars), and I was wondering what I set the row and cols to ....

>
> Wouldn't <pre> make more sense than <textarea>?


Partly. It would avoid misleading the user into thinking that there is a
text input area, which is what textarea is for.

But there's usually no reason to use clumsy preformatted text in HTML at
all. Why would anyone write plain text formatted to specific line length
when you can do things the HTML way, with paragraph markup and all that?

As usual, posting a description of a problem, rather than a misguided
attempt to approach an unspecified problem, would probably lead to a good
solution. Especially if pointless crossposting is omitted.

Followups trimmed.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
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
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Inserting Controls Dynamically - with Validators Also Added Dynamically Jeffrey Todd ASP .Net 1 06-02-2005 04:33 PM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-05-2005 12:04 AM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-04-2005 07:57 PM



Advertisments