meediake
05-29-2006, 01:51 PM
Hello everybody,
I try to make a function, what resizes my textarea. Everything is OK, but it is not resizing normally. I have a problem writing my function to count lines in textarea(also these lines, which are wrapped).
Does anybody have an idea or allready a correctly functioning function to count lines?
My own function looks like this:
function count_lines(strtocount, cols) {
var hard_lines = 1;
var last = 0;
while (true) {
last = strtocount.indexOf("\n", last+1);
hard_lines ++;
if ( last == -1 ) break;
}
var soft_lines = Math.round(strtocount.length / (cols-1));
var hard = eval('hard_lines ' + unescape('%3e') + 'soft_lines;');
if (hard) soft_lines = hard_lines;
return soft_lines;
}
thank you !
I try to make a function, what resizes my textarea. Everything is OK, but it is not resizing normally. I have a problem writing my function to count lines in textarea(also these lines, which are wrapped).
Does anybody have an idea or allready a correctly functioning function to count lines?
My own function looks like this:
function count_lines(strtocount, cols) {
var hard_lines = 1;
var last = 0;
while (true) {
last = strtocount.indexOf("\n", last+1);
hard_lines ++;
if ( last == -1 ) break;
}
var soft_lines = Math.round(strtocount.length / (cols-1));
var hard = eval('hard_lines ' + unescape('%3e') + 'soft_lines;');
if (hard) soft_lines = hard_lines;
return soft_lines;
}
thank you !