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,928
12년 전 조회 2,069
12년 전 조회 4,244
12년 전 조회 3,256
12년 전 조회 2,931
12년 전 조회 2,609
12년 전 조회 2,289
12년 전 조회 2,307
12년 전 조회 2,043
12년 전 조회 3,120
12년 전 조회 2,438
12년 전 조회 2,143
12년 전 조회 3,205
12년 전 조회 2,390
12년 전 조회 2,979
12년 전 조회 4,201
12년 전 조회 1,953
12년 전 조회 2,933
12년 전 조회 1,792
12년 전 조회 2,277
12년 전 조회 2,915
12년 전 조회 2,518
12년 전 조회 5,329
12년 전 조회 3,444
12년 전 조회 3,640
12년 전 조회 2,002
12년 전 조회 9,327
12년 전 조회 4,141
12년 전 조회 2,202
12년 전 조회 2,068
12년 전 조회 3,496
12년 전 조회 6,184
12년 전 조회 4,199
12년 전 조회 2,112
12년 전 조회 1.4만
12년 전 조회 1,989
12년 전 조회 1,420
12년 전 조회 4,785
12년 전 조회 2,263
12년 전 조회 1만
12년 전 조회 1,591
12년 전 조회 2,036
12년 전 조회 4,038
12년 전 조회 1,670
12년 전 조회 2,573
12년 전 조회 4,558
12년 전 조회 1,866
13년 전 조회 1,754
13년 전 조회 6,124
13년 전 조회 2,255
13년 전 조회 1,587
13년 전 조회 3,322
13년 전 조회 3,311
13년 전 조회 2,302
13년 전 조회 3,718
13년 전 조회 7,404
13년 전 조회 2,985
13년 전 조회 1,548
13년 전 조회 2,708
13년 전 조회 2,678
13년 전 조회 3,423
13년 전 조회 1,400
13년 전 조회 2,492
13년 전 조회 1,568
13년 전 조회 2,573
13년 전 조회 3,480
13년 전 조회 2,054
13년 전 조회 4,683
13년 전 조회 1.1만
13년 전 조회 1,945
13년 전 조회 3,318
13년 전 조회 2,938
13년 전 조회 3,863
13년 전 조회 6,849
13년 전 조회 3,506
13년 전 조회 3,822
13년 전 조회 1,789
13년 전 조회 1,560
13년 전 조회 2,667
13년 전 조회 6,666
13년 전 조회 2,288
13년 전 조회 5,523
13년 전 조회 1,707
13년 전 조회 4,923
13년 전 조회 2,083
13년 전 조회 1,893
13년 전 조회 2,450
13년 전 조회 2,079
13년 전 조회 1,345
13년 전 조회 1,322
13년 전 조회 2.1만
13년 전 조회 1,290
13년 전 조회 1,857
13년 전 조회 1,882
13년 전 조회 2,100
13년 전 조회 4,245
13년 전 조회 1,462
13년 전 조회 3,003
13년 전 조회 5,665
13년 전 조회 1,444