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,337
12년 전 조회 1,490
12년 전 조회 3,677
12년 전 조회 2,706
12년 전 조회 2,412
12년 전 조회 2,042
12년 전 조회 1,731
12년 전 조회 1,725
12년 전 조회 1,479
12년 전 조회 2,596
12년 전 조회 1,875
12년 전 조회 1,546
12년 전 조회 2,631
12년 전 조회 1,810
12년 전 조회 2,429
12년 전 조회 3,644
12년 전 조회 1,430
12년 전 조회 2,386
12년 전 조회 1,240
12년 전 조회 1,731
12년 전 조회 2,308
12년 전 조회 1,941
12년 전 조회 4,760
12년 전 조회 2,860
12년 전 조회 3,032
12년 전 조회 1,406
12년 전 조회 8,727
12년 전 조회 3,539
12년 전 조회 1,627
12년 전 조회 1,488
12년 전 조회 2,876
12년 전 조회 5,557
12년 전 조회 3,609
12년 전 조회 1,540
12년 전 조회 1.4만
12년 전 조회 1,403
12년 전 조회 813
12년 전 조회 4,122
12년 전 조회 1,629
12년 전 조회 9,524
12년 전 조회 989
12년 전 조회 1,436
12년 전 조회 3,408
12년 전 조회 1,049
12년 전 조회 1,949
12년 전 조회 3,853
12년 전 조회 1,258
12년 전 조회 1,163
12년 전 조회 5,499
12년 전 조회 1,629
12년 전 조회 956
12년 전 조회 2,774
12년 전 조회 2,686
12년 전 조회 1,701
12년 전 조회 3,141
12년 전 조회 6,748
12년 전 조회 2,341
12년 전 조회 944
12년 전 조회 2,107
12년 전 조회 2,035
12년 전 조회 2,807
12년 전 조회 796
12년 전 조회 1,892
12년 전 조회 979
12년 전 조회 1,958
12년 전 조회 2,885
12년 전 조회 1,438
12년 전 조회 4,071
12년 전 조회 1만
12년 전 조회 1,306
12년 전 조회 2,640
12년 전 조회 2,326
12년 전 조회 3,186
12년 전 조회 6,209
12년 전 조회 2,825
12년 전 조회 3,171
12년 전 조회 1,166
12년 전 조회 957
12년 전 조회 2,052
13년 전 조회 6,064
13년 전 조회 1,669
13년 전 조회 4,904
13년 전 조회 1,129
13년 전 조회 4,298
13년 전 조회 1,435
13년 전 조회 1,290
13년 전 조회 1,866
13년 전 조회 1,505
13년 전 조회 766
13년 전 조회 736
13년 전 조회 2.1만
13년 전 조회 705
13년 전 조회 1,273
13년 전 조회 1,278
13년 전 조회 1,508
13년 전 조회 3,664
13년 전 조회 905
13년 전 조회 2,404
13년 전 조회 5,084
13년 전 조회 865