Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > find textarea number of cols when it is set to 100%

Reply
Thread Tools

find textarea number of cols when it is set to 100%

 
 
arnaud
Guest
Posts: n/a
 
      07-20-2004
Hi,
I have an application whose textareas rows automatically resize onFocus
to the number of lines in the textArea.
The cols are set to 100% (in a CSS file) in order to always take the
full browser width

I use textarea.value.split('\n') to find the number of lines.
Some lines are longer than the 100% width and they wrap.
However, wrappeed lines do not contain '\n'. Thus my textarea has less
lines than what is needed to display it without scroll bars.

I don't want to use wrap='hard' as the text shall be stored in the DB in
its original form (even if lines are too long to be displayed without
wrapping).

I would like thus to get the number of cols dynamically
in order to do:
lines=textarea.value.split('\n');
realNumberOfLines=0;
for(i=0; 1<lines.length; i++) {
realNumberOfLines = realNumberOfLines +
Math.ceil(lines[i].length/textarea.cols);
}
return realNumberOfLines;


The problem is that textare.cols returns -1 in mozilla 1.7 and a value
lower than the reality in IE6.

Does anybody have an idea on how to achieve that?

Regards,
Arnaud.

 
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
Tetration (print 100^100^100^100^100^100^100^100^100^100^100^100^100^100) jononanon@googlemail.com C Programming 5 04-25-2012 08:49 PM
Free cPanel web hosting worth $100 for your Domain! 100 MB Web Space + Email + MySQL Database + FTP Access & More. 100% Free, No Hidden Fees! - cena Computer Support 0 10-30-2007 08:46 PM
Free cPanel web hosting worth $100 for your Domain! 100 MB Web Space + Email + MySQL Database + FTP Access & More. 100% Free, No Hidden Fees! - Vetri HTML 0 10-02-2007 04:59 AM
hot to align inner table cols with outer table cols phl HTML 2 05-23-2006 10:58 AM
[Repost] find textarea number of cols when it is set to 100% nospam Javascript 1 07-22-2004 03:44 PM



Advertisments