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,639
13년 전 조회 2,811
13년 전 조회 4,990
13년 전 조회 4,000
13년 전 조회 3,680
13년 전 조회 3,357
13년 전 조회 3,032
13년 전 조회 3,009
13년 전 조회 2,771
13년 전 조회 3,898
13년 전 조회 3,208
13년 전 조회 2,824
13년 전 조회 3,915
13년 전 조회 3,119
13년 전 조회 3,719
13년 전 조회 4,941
13년 전 조회 2,703
13년 전 조회 3,665
13년 전 조회 2,503
13년 전 조회 2,990
13년 전 조회 3,601
13년 전 조회 3,261
13년 전 조회 6,059
13년 전 조회 4,177
13년 전 조회 4,347
13년 전 조회 2,725
13년 전 조회 1만
13년 전 조회 4,860
13년 전 조회 2,933
13년 전 조회 2,808
13년 전 조회 4,202
13년 전 조회 6,927
13년 전 조회 4,918
13년 전 조회 2,845
13년 전 조회 1.5만
13년 전 조회 2,722
13년 전 조회 2,153
13년 전 조회 5,248
13년 전 조회 2,726
13년 전 조회 1.1만
13년 전 조회 2,336
13년 전 조회 2,567
13년 전 조회 4,774
13년 전 조회 2,374
13년 전 조회 3,290
13년 전 조회 5,207
13년 전 조회 2,577
13년 전 조회 2,486
13년 전 조회 6,867
13년 전 조회 2,960
13년 전 조회 2,277
13년 전 조회 4,029
13년 전 조회 4,061
13년 전 조회 3,026
13년 전 조회 4,462
13년 전 조회 8,127
13년 전 조회 3,689
13년 전 조회 2,299
13년 전 조회 3,432
13년 전 조회 3,390
13년 전 조회 4,149
13년 전 조회 2,149
13년 전 조회 3,250
13년 전 조회 2,099
13년 전 조회 3,317
13년 전 조회 4,218
13년 전 조회 2,549
13년 전 조회 5,440
13년 전 조회 1.2만
13년 전 조회 2,673
13년 전 조회 4,063
13년 전 조회 3,667
13년 전 조회 4,338
13년 전 조회 7,614
13년 전 조회 3,974
13년 전 조회 4,566
13년 전 조회 2,574
13년 전 조회 2,309
13년 전 조회 3,415
13년 전 조회 7,432
13년 전 조회 3,007
13년 전 조회 6,305
13년 전 조회 2,229
13년 전 조회 5,656
13년 전 조회 2,811
13년 전 조회 2,655
13년 전 조회 2,934
13년 전 조회 2,852
13년 전 조회 2,096
13년 전 조회 2,077
13년 전 조회 2.2만
13년 전 조회 2,032
13년 전 조회 2,631
13년 전 조회 2,602
13년 전 조회 2,865
13년 전 조회 5,043
13년 전 조회 2,251
13년 전 조회 3,738
13년 전 조회 6,378
13년 전 조회 2,215