原始码是这样:
<textarea cols=80 rows="6" name=abc style="overflow-auto">I miss you a lot.....</textarea>
因为初始值"I miss you a lot..."这一段长度不定.我想在长度小于6行时
该窗口就显示它实际用的窗口大小.大于6行就显示6行加滚动条.
基本想发是先计算字符长度.再给rows=赋值.
我试了好象不行
不知是否可以给rows(赋值  或用<style  height:...>.
谢谢!
     

解决方案 »

  1.   

    you can use javascript to change the attribute's value.
      

  2.   

    可以给rows赋值来改变行数
    height不行
      

  3.   

    如果rows可以的话,可以给个实例吗? 我试过好象不行.
    楼上说用javascript,可以详细说吗?
    我是这样做:
    < script>
    .......
    var ll=50px;
    </script>
    <body>
    .....
    <textarea cols=80 rows=ll name=abc style="overflow:auto">
    1.this is first line.
    2.this is second line.
    3.this is third line.
    </textarea>
    ............
    ............
    or
    <div style="height:ll;overflow:auto....>......
    .....
    </div>
    都不行.
    有没有什么好办法?
    谢谢!
      

  4.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    </head><body>..... 
    <!--指定TEXTAREA的ID-->
    <textarea   cols=4   rows=16  id=abc  name=abc > 
    1.this   is   first   line. 
    2.this   is   second   line. 
    3.this   is   third   line. 
    </textarea> 
    <script language=javascript>
    function test()
    {
    //通过"name"属性取得TEXTAREA,下面的设置不起作用
    //var text = document.getElementByName("abc");
    //通过ID属性取得TEXTAREA
    var text = document.getElementById("abc");
    //设置overflow
    text.style.overflow="visible";
    //设置宽度
    text.rows=10;
    }
    test();
    </script>
    </body></html>
      

  5.   

    document.getElementById('table name').rows(0).style.height = '20px';
      

  6.   

    要是想赋变量的话可以用expression()
    好比:
    style{
        div{
           ……
            height:expression(getHeight());
           ……
        }
    }
    ……
    <script language="javascript">
    function getHeight()
    {
        //具体指定高度的函数
        ……
        return 返回高度;
    }
    </script>或者就是直接在脚本里随时改动了。