|
|
|
новичок
      
участник
Last Login: 26.04.2007 0:31
Сообщ.: 5,
Visits: 13
|
|
Помогите, пожалуйста! Как сделать, чтобы при нажатии кнопок увеличить/уменьшить, размер текстового поля(textarea) соответственного вертикально увеличивался/уменьшался. Есть готовый пример, но никак не получается его переделать, чтобы он работал, при нажатии кнопок увеличить/уменьшить, работает только при нажатии , . Помогите переделать код или может быть у кого-нибудь есть более простое решение данной задачи? готовый пример:
body onload="cleanForm();"
script type="text/javascript"
function countLines(strtocount, cols) {
var hard_lines = 1;
var last = 0;
while ( true ) {
last = strtocount.indexOf("", 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;
}
function cleanForm() {
var the_form = document.forms[0];
for ( var x in the_form ) {
if ( ! the_form[x] ) continue;
if( typeof the_form[x].rows != "number" ) continue;
the_form[x].rows = countLines(the_form[x].value,the_form[x].cols) +1;
}
setTimeout("cleanForm();", 300);
}
/script
form action="index.php" method="get"
textarea cols="60" rows="2" name="reason" /textarea
/form
|
|
|
|
|
Supreme Being
      
участник
Last Login: 29.05.2008 20:04
Сообщ.: 269,
Visits: 2 381
|
|
<html> <head> <title> </title> <script> var a=50,c=0; function A(q) { if (q==1 && (a+c)>0) {c+=10;} else if (q==0 && (a+c)>0) {c-=10;} document.f.q.rows=((a+c)<1)?(a+c+10):(a+c); document.f.q.cols=((a+c)<1)?(a+c+10):(a+c); alert(a+c); } </script> </head> <body> <form name="f"> <textarea name="q" rows="50" cols="50"> </textarea> <input type="button" onclick="A(0)" value="-"> <input type="button" onclick="A(1)" value="+"> </form> </body> </html>
----------------------------------
Я безработный...
Возьмите меня на работу. =)
|
|
|
|
|
новичок
      
участник
Last Login: 26.04.2007 0:31
Сообщ.: 5,
Visits: 13
|
|
| Огромное СПАСИБО!!!!!!!!!)))
|
|
|
|