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,397
12년 전 조회 1,546
12년 전 조회 3,733
12년 전 조회 2,758
12년 전 조회 2,465
12년 전 조회 2,099
12년 전 조회 1,781
12년 전 조회 1,785
12년 전 조회 1,530
12년 전 조회 2,655
12년 전 조회 1,931
12년 전 조회 1,608
12년 전 조회 2,691
12년 전 조회 1,869
12년 전 조회 2,482
12년 전 조회 3,702
12년 전 조회 1,494
12년 전 조회 2,448
12년 전 조회 1,304
12년 전 조회 1,794
12년 전 조회 2,370
12년 전 조회 2,002
12년 전 조회 4,814
12년 전 조회 2,918
12년 전 조회 3,096
12년 전 조회 1,460
12년 전 조회 8,779
12년 전 조회 3,605
12년 전 조회 1,678
12년 전 조회 1,545
12년 전 조회 2,934
12년 전 조회 5,616
12년 전 조회 3,658
12년 전 조회 1,597
12년 전 조회 1.4만
12년 전 조회 1,462
12년 전 조회 869
12년 전 조회 4,182
12년 전 조회 1,681
12년 전 조회 9,571
12년 전 조회 1,051
12년 전 조회 1,488
12년 전 조회 3,454
12년 전 조회 1,106
12년 전 조회 2,008
12년 전 조회 3,912
12년 전 조회 1,322
12년 전 조회 1,225
12년 전 조회 5,550
12년 전 조회 1,691
12년 전 조회 1,020
12년 전 조회 2,807
12년 전 조회 2,741
12년 전 조회 1,754
12년 전 조회 3,187
12년 전 조회 6,811
12년 전 조회 2,391
12년 전 조회 993
12년 전 조회 2,154
12년 전 조회 2,078
12년 전 조회 2,856
12년 전 조회 853
12년 전 조회 1,940
12년 전 조회 1,024
12년 전 조회 2,000
12년 전 조회 2,934
12년 전 조회 1,495
12년 전 조회 4,132
12년 전 조회 1만
12년 전 조회 1,356
12년 전 조회 2,705
12년 전 조회 2,382
12년 전 조회 3,243
12년 전 조회 6,261
12년 전 조회 2,873
12년 전 조회 3,216
12년 전 조회 1,221
13년 전 조회 1,013
13년 전 조회 2,105
13년 전 조회 6,114
13년 전 조회 1,720
13년 전 조회 4,957
13년 전 조회 1,176
13년 전 조회 4,345
13년 전 조회 1,484
13년 전 조회 1,337
13년 전 조회 1,918
13년 전 조회 1,556
13년 전 조회 808
13년 전 조회 789
13년 전 조회 2.1만
13년 전 조회 748
13년 전 조회 1,325
13년 전 조회 1,328
13년 전 조회 1,554
13년 전 조회 3,718
13년 전 조회 962
13년 전 조회 2,447
13년 전 조회 5,133
13년 전 조회 908