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,382
12년 전 조회 1,534
12년 전 조회 3,721
12년 전 조회 2,743
12년 전 조회 2,453
12년 전 조회 2,086
12년 전 조회 1,769
12년 전 조회 1,762
12년 전 조회 1,516
12년 전 조회 2,641
12년 전 조회 1,914
12년 전 조회 1,600
12년 전 조회 2,679
12년 전 조회 1,854
12년 전 조회 2,467
12년 전 조회 3,689
12년 전 조회 1,475
12년 전 조회 2,433
12년 전 조회 1,284
12년 전 조회 1,775
12년 전 조회 2,348
12년 전 조회 1,987
12년 전 조회 4,805
12년 전 조회 2,900
12년 전 조회 3,081
12년 전 조회 1,445
12년 전 조회 8,763
12년 전 조회 3,585
12년 전 조회 1,666
12년 전 조회 1,533
12년 전 조회 2,921
12년 전 조회 5,590
12년 전 조회 3,644
12년 전 조회 1,580
12년 전 조회 1.4만
12년 전 조회 1,449
12년 전 조회 851
12년 전 조회 4,166
12년 전 조회 1,666
12년 전 조회 9,558
12년 전 조회 1,028
12년 전 조회 1,479
12년 전 조회 3,440
12년 전 조회 1,087
12년 전 조회 1,992
12년 전 조회 3,892
12년 전 조회 1,300
12년 전 조회 1,201
12년 전 조회 5,534
12년 전 조회 1,667
12년 전 조회 999
12년 전 조회 2,793
12년 전 조회 2,722
12년 전 조회 1,737
12년 전 조회 3,169
12년 전 조회 6,788
12년 전 조회 2,377
12년 전 조회 978
12년 전 조회 2,134
12년 전 조회 2,066
12년 전 조회 2,840
12년 전 조회 831
12년 전 조회 1,925
12년 전 조회 1,010
12년 전 조회 1,987
12년 전 조회 2,916
12년 전 조회 1,473
12년 전 조회 4,112
12년 전 조회 1만
12년 전 조회 1,347
12년 전 조회 2,683
12년 전 조회 2,357
12년 전 조회 3,220
12년 전 조회 6,245
12년 전 조회 2,859
12년 전 조회 3,201
12년 전 조회 1,203
13년 전 조회 993
13년 전 조회 2,091
13년 전 조회 6,093
13년 전 조회 1,705
13년 전 조회 4,938
13년 전 조회 1,160
13년 전 조회 4,331
13년 전 조회 1,461
13년 전 조회 1,324
13년 전 조회 1,900
13년 전 조회 1,541
13년 전 조회 790
13년 전 조회 768
13년 전 조회 2.1만
13년 전 조회 734
13년 전 조회 1,316
13년 전 조회 1,311
13년 전 조회 1,540
13년 전 조회 3,702
13년 전 조회 940
13년 전 조회 2,432
13년 전 조회 5,112
13년 전 조회 890