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개

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

프로그램

+
제목 글쓴이 날짜 조회
13년 전 조회 3,469
13년 전 조회 2,670
13년 전 조회 4,837
13년 전 조회 3,825
13년 전 조회 3,522
13년 전 조회 3,190
13년 전 조회 2,864
13년 전 조회 2,858
13년 전 조회 2,598
13년 전 조회 3,728
13년 전 조회 3,026
13년 전 조회 2,662
13년 전 조회 3,737
13년 전 조회 2,962
13년 전 조회 3,540
13년 전 조회 4,780
13년 전 조회 2,540
13년 전 조회 3,515
13년 전 조회 2,358
13년 전 조회 2,820
13년 전 조회 3,450
13년 전 조회 3,089
13년 전 조회 5,895
13년 전 조회 3,994
13년 전 조회 4,182
13년 전 조회 2,539
13년 전 조회 9,881
13년 전 조회 4,706
13년 전 조회 2,764
13년 전 조회 2,643
13년 전 조회 4,032
13년 전 조회 6,747
13년 전 조회 4,754
13년 전 조회 2,685
13년 전 조회 1.5만
13년 전 조회 2,549
13년 전 조회 1,971
13년 전 조회 5,162
13년 전 조회 2,649
13년 전 조회 1.1만
13년 전 조회 2,156
13년 전 조회 2,478
13년 전 조회 4,595
13년 전 조회 2,207
13년 전 조회 3,104
13년 전 조회 5,030
13년 전 조회 2,412
13년 전 조회 2,310
13년 전 조회 6,689
13년 전 조회 2,785
13년 전 조회 2,098
13년 전 조회 3,864
13년 전 조회 3,881
13년 전 조회 2,855
13년 전 조회 4,282
13년 전 조회 7,949
13년 전 조회 3,509
13년 전 조회 2,122
13년 전 조회 3,261
13년 전 조회 3,213
13년 전 조회 3,979
13년 전 조회 1,975
13년 전 조회 3,078
13년 전 조회 2,023
13년 전 조회 3,135
13년 전 조회 4,056
13년 전 조회 2,452
13년 전 조회 5,262
13년 전 조회 1.1만
13년 전 조회 2,515
13년 전 조회 3,859
13년 전 조회 3,488
13년 전 조회 4,254
13년 전 조회 7,401
13년 전 조회 3,887
13년 전 조회 4,378
13년 전 조회 2,369
13년 전 조회 2,134
13년 전 조회 3,230
13년 전 조회 7,241
13년 전 조회 2,821
13년 전 조회 6,114
13년 전 조회 2,147
13년 전 조회 5,481
13년 전 조회 2,640
13년 전 조회 2,484
13년 전 조회 2,857
13년 전 조회 2,664
13년 전 조회 1,919
13년 전 조회 1,902
13년 전 조회 2.2만
13년 전 조회 1,846
13년 전 조회 2,441
13년 전 조회 2,442
13년 전 조회 2,689
13년 전 조회 4,844
13년 전 조회 2,075
13년 전 조회 3,551
13년 전 조회 6,196
13년 전 조회 2,047