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,713
12년 전 조회 1,861
12년 전 조회 4,036
12년 전 조회 3,058
12년 전 조회 2,749
12년 전 조회 2,432
12년 전 조회 2,096
12년 전 조회 2,114
12년 전 조회 1,846
12년 전 조회 2,943
12년 전 조회 2,242
12년 전 조회 1,951
12년 전 조회 3,012
12년 전 조회 2,209
12년 전 조회 2,788
12년 전 조회 4,013
12년 전 조회 1,774
12년 전 조회 2,761
12년 전 조회 1,604
12년 전 조회 2,104
12년 전 조회 2,714
12년 전 조회 2,324
12년 전 조회 5,123
12년 전 조회 3,252
12년 전 조회 3,435
12년 전 조회 1,777
12년 전 조회 9,099
12년 전 조회 3,943
12년 전 조회 1,985
12년 전 조회 1,853
12년 전 조회 3,279
12년 전 조회 5,959
12년 전 조회 3,995
12년 전 조회 1,911
12년 전 조회 1.4만
12년 전 조회 1,763
12년 전 조회 1,188
12년 전 조회 4,555
12년 전 조회 2,052
12년 전 조회 9,888
12년 전 조회 1,375
12년 전 조회 1,861
12년 전 조회 3,807
12년 전 조회 1,435
12년 전 조회 2,342
12년 전 조회 4,298
12년 전 조회 1,626
12년 전 조회 1,527
12년 전 조회 5,906
12년 전 조회 2,032
12년 전 조회 1,367
12년 전 조회 3,116
12년 전 조회 3,084
12년 전 조회 2,085
12년 전 조회 3,516
12년 전 조회 7,176
12년 전 조회 2,742
12년 전 조회 1,310
12년 전 조회 2,478
12년 전 조회 2,453
12년 전 조회 3,195
12년 전 조회 1,170
12년 전 조회 2,273
12년 전 조회 1,397
12년 전 조회 2,357
13년 전 조회 3,272
13년 전 조회 1,876
13년 전 조회 4,463
13년 전 조회 1.1만
13년 전 조회 1,705
13년 전 조회 3,097
13년 전 조회 2,715
13년 전 조회 3,642
13년 전 조회 6,600
13년 전 조회 3,271
13년 전 조회 3,583
13년 전 조회 1,562
13년 전 조회 1,340
13년 전 조회 2,434
13년 전 조회 6,449
13년 전 조회 2,057
13년 전 조회 5,272
13년 전 조회 1,504
13년 전 조회 4,681
13년 전 조회 1,859
13년 전 조회 1,675
13년 전 조회 2,258
13년 전 조회 1,862
13년 전 조회 1,126
13년 전 조회 1,093
13년 전 조회 2.1만
13년 전 조회 1,064
13년 전 조회 1,636
13년 전 조회 1,654
13년 전 조회 1,892
13년 전 조회 4,030
13년 전 조회 1,256
13년 전 조회 2,794
13년 전 조회 5,466
13년 전 조회 1,228