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,344
12년 전 조회 1,498
12년 전 조회 3,683
12년 전 조회 2,711
12년 전 조회 2,419
12년 전 조회 2,049
12년 전 조회 1,735
12년 전 조회 1,736
12년 전 조회 1,485
12년 전 조회 2,604
12년 전 조회 1,880
12년 전 조회 1,553
12년 전 조회 2,638
12년 전 조회 1,814
12년 전 조회 2,434
12년 전 조회 3,651
12년 전 조회 1,436
12년 전 조회 2,394
12년 전 조회 1,244
12년 전 조회 1,736
12년 전 조회 2,311
12년 전 조회 1,948
12년 전 조회 4,766
12년 전 조회 2,865
12년 전 조회 3,035
12년 전 조회 1,415
12년 전 조회 8,734
12년 전 조회 3,548
12년 전 조회 1,634
12년 전 조회 1,494
12년 전 조회 2,881
12년 전 조회 5,562
12년 전 조회 3,614
12년 전 조회 1,543
12년 전 조회 1.4만
12년 전 조회 1,408
12년 전 조회 817
12년 전 조회 4,126
12년 전 조회 1,638
12년 전 조회 9,528
12년 전 조회 993
12년 전 조회 1,442
12년 전 조회 3,410
12년 전 조회 1,056
12년 전 조회 1,956
12년 전 조회 3,860
12년 전 조회 1,262
12년 전 조회 1,168
12년 전 조회 5,501
12년 전 조회 1,634
12년 전 조회 966
12년 전 조회 2,779
12년 전 조회 2,695
12년 전 조회 1,706
12년 전 조회 3,145
12년 전 조회 6,752
12년 전 조회 2,346
12년 전 조회 949
12년 전 조회 2,110
12년 전 조회 2,042
12년 전 조회 2,812
12년 전 조회 799
12년 전 조회 1,892
12년 전 조회 984
12년 전 조회 1,966
12년 전 조회 2,892
12년 전 조회 1,446
12년 전 조회 4,079
12년 전 조회 1만
12년 전 조회 1,319
12년 전 조회 2,648
12년 전 조회 2,333
12년 전 조회 3,191
12년 전 조회 6,215
12년 전 조회 2,832
12년 전 조회 3,177
12년 전 조회 1,173
12년 전 조회 963
13년 전 조회 2,056
13년 전 조회 6,069
13년 전 조회 1,673
13년 전 조회 4,908
13년 전 조회 1,134
13년 전 조회 4,301
13년 전 조회 1,442
13년 전 조회 1,292
13년 전 조회 1,873
13년 전 조회 1,510
13년 전 조회 771
13년 전 조회 743
13년 전 조회 2.1만
13년 전 조회 710
13년 전 조회 1,277
13년 전 조회 1,281
13년 전 조회 1,515
13년 전 조회 3,669
13년 전 조회 909
13년 전 조회 2,409
13년 전 조회 5,086
13년 전 조회 868