s

textarea 자동 늘려주기 2

<script type="text/javascript" language="JavaScript">
<!--
function countLineBreaks (string) {
    var re = /\r\n|\r|\n/g;
    var n = 0;
    while(re.exec(string)){
        n++;
    }
    return n;
}
function add_rows(){

    var oText = document.getElementById('sc_content');  //textarea id
    if(document.all) {    // IE
        while (oText.scrollHeight > oText.clientHeight){
            oText.rows++;
            oText.scrollTop = 0;
        }
        while(oText.scrollHeight < oText.clientHeight && oText.rows != 4){ // 기본 rows
            oText.rows--;
            oText.scrollTop = 0;
        }
    }else if(oText.rows) {    // IE 외
        var lineBreaks = countLineBreaks(oText.value);
        var rows = parseInt(oText.rows);
        if(lineBreaks > rows){
            oText.rows = ++rows;
        }else if(lineBreaks < rows && oText.rows != 4){  // 기본 rows
            oText.rows = --rows;
        }else{
            while (oText.rows * oText.cols <= oText.value.length) {
                oText.rows = ++rows;
            }
        }
    }
}
//-->
</script>

<textarea id="sc_content" name="sc_content" onkeypress="add_rows()" rows=4 cols=80></textarea>
|

댓글 1개

댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
12년 전 조회 2,965
12년 전 조회 2,112
12년 전 조회 4,280
12년 전 조회 3,301
12년 전 조회 2,975
12년 전 조회 2,642
12년 전 조회 2,330
12년 전 조회 2,346
12년 전 조회 2,086
12년 전 조회 3,162
12년 전 조회 2,479
12년 전 조회 2,179
12년 전 조회 3,242
12년 전 조회 2,428
12년 전 조회 3,014
12년 전 조회 4,235
12년 전 조회 1,989
12년 전 조회 2,979
12년 전 조회 1,828
12년 전 조회 2,308
12년 전 조회 2,949
12년 전 조회 2,573
12년 전 조회 5,367
12년 전 조회 3,495
12년 전 조회 3,683
12년 전 조회 2,046
12년 전 조회 9,364
12년 전 조회 4,183
12년 전 조회 2,232
12년 전 조회 2,105
13년 전 조회 3,536
13년 전 조회 6,217
13년 전 조회 4,240
13년 전 조회 2,146
13년 전 조회 1.4만
13년 전 조회 2,021
13년 전 조회 1,446
13년 전 조회 4,794
13년 전 조회 2,283
13년 전 조회 1만
13년 전 조회 1,623
13년 전 조회 2,048
13년 전 조회 4,081
13년 전 조회 1,708
13년 전 조회 2,603
13년 전 조회 4,590
13년 전 조회 1,900
13년 전 조회 1,789
13년 전 조회 6,162
13년 전 조회 2,286
13년 전 조회 1,618
13년 전 조회 3,354
13년 전 조회 3,350
13년 전 조회 2,332
13년 전 조회 3,748
13년 전 조회 7,440
13년 전 조회 3,015
13년 전 조회 1,576
13년 전 조회 2,741
13년 전 조회 2,714
13년 전 조회 3,458
13년 전 조회 1,424
13년 전 조회 2,524
13년 전 조회 1,574
13년 전 조회 2,621
13년 전 조회 3,514
13년 전 조회 2,057
13년 전 조회 4,711
13년 전 조회 1.1만
13년 전 조회 1,976
13년 전 조회 3,346
13년 전 조회 2,970
13년 전 조회 3,871
13년 전 조회 6,889
13년 전 조회 3,522
13년 전 조회 3,861
13년 전 조회 1,832
13년 전 조회 1,599
13년 전 조회 2,702
13년 전 조회 6,708
13년 전 조회 2,316
13년 전 조회 5,553
13년 전 조회 1,720
13년 전 조회 4,964
13년 전 조회 2,119
13년 전 조회 1,924
13년 전 조회 2,463
13년 전 조회 2,115
13년 전 조회 1,375
13년 전 조회 1,347
13년 전 조회 2.1만
13년 전 조회 1,319
13년 전 조회 1,879
13년 전 조회 1,915
13년 전 조회 2,144
13년 전 조회 4,290
13년 전 조회 1,504
13년 전 조회 3,034
13년 전 조회 5,697
13년 전 조회 1,472