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,930
12년 전 조회 2,073
12년 전 조회 4,245
12년 전 조회 3,258
12년 전 조회 2,931
12년 전 조회 2,610
12년 전 조회 2,289
12년 전 조회 2,308
12년 전 조회 2,046
12년 전 조회 3,122
12년 전 조회 2,439
12년 전 조회 2,144
12년 전 조회 3,205
12년 전 조회 2,392
12년 전 조회 2,981
12년 전 조회 4,202
12년 전 조회 1,958
12년 전 조회 2,936
12년 전 조회 1,796
12년 전 조회 2,278
12년 전 조회 2,916
12년 전 조회 2,523
12년 전 조회 5,333
12년 전 조회 3,446
12년 전 조회 3,641
12년 전 조회 2,004
12년 전 조회 9,330
12년 전 조회 4,141
12년 전 조회 2,202
12년 전 조회 2,071
12년 전 조회 3,501
12년 전 조회 6,189
12년 전 조회 4,200
12년 전 조회 2,113
12년 전 조회 1.4만
12년 전 조회 1,990
12년 전 조회 1,422
12년 전 조회 4,787
12년 전 조회 2,264
12년 전 조회 1만
12년 전 조회 1,594
12년 전 조회 2,036
12년 전 조회 4,038
12년 전 조회 1,672
12년 전 조회 2,573
12년 전 조회 4,559
12년 전 조회 1,870
13년 전 조회 1,756
13년 전 조회 6,127
13년 전 조회 2,259
13년 전 조회 1,591
13년 전 조회 3,325
13년 전 조회 3,313
13년 전 조회 2,303
13년 전 조회 3,718
13년 전 조회 7,406
13년 전 조회 2,985
13년 전 조회 1,548
13년 전 조회 2,710
13년 전 조회 2,679
13년 전 조회 3,425
13년 전 조회 1,402
13년 전 조회 2,493
13년 전 조회 1,569
13년 전 조회 2,578
13년 전 조회 3,482
13년 전 조회 2,054
13년 전 조회 4,685
13년 전 조회 1.1만
13년 전 조회 1,948
13년 전 조회 3,319
13년 전 조회 2,940
13년 전 조회 3,865
13년 전 조회 6,851
13년 전 조회 3,508
13년 전 조회 3,824
13년 전 조회 1,789
13년 전 조회 1,561
13년 전 조회 2,668
13년 전 조회 6,668
13년 전 조회 2,289
13년 전 조회 5,525
13년 전 조회 1,710
13년 전 조회 4,923
13년 전 조회 2,086
13년 전 조회 1,893
13년 전 조회 2,451
13년 전 조회 2,080
13년 전 조회 1,349
13년 전 조회 1,323
13년 전 조회 2.1만
13년 전 조회 1,292
13년 전 조회 1,857
13년 전 조회 1,883
13년 전 조회 2,101
13년 전 조회 4,248
13년 전 조회 1,466
13년 전 조회 3,005
13년 전 조회 5,667
13년 전 조회 1,446