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년 전 조회 3,077
12년 전 조회 2,217
12년 전 조회 4,413
12년 전 조회 3,420
12년 전 조회 3,099
12년 전 조회 2,763
12년 전 조회 2,449
12년 전 조회 2,466
12년 전 조회 2,206
12년 전 조회 3,282
12년 전 조회 2,606
12년 전 조회 2,289
12년 전 조회 3,357
12년 전 조회 2,546
12년 전 조회 3,138
12년 전 조회 4,342
12년 전 조회 2,089
12년 전 조회 3,096
12년 전 조회 1,953
13년 전 조회 2,414
13년 전 조회 3,070
13년 전 조회 2,677
13년 전 조회 5,487
13년 전 조회 3,606
13년 전 조회 3,779
13년 전 조회 2,167
13년 전 조회 9,471
13년 전 조회 4,286
13년 전 조회 2,349
13년 전 조회 2,201
13년 전 조회 3,641
13년 전 조회 6,326
13년 전 조회 4,350
13년 전 조회 2,258
13년 전 조회 1.4만
13년 전 조회 2,137
13년 전 조회 1,546
13년 전 조회 4,824
13년 전 조회 2,329
13년 전 조회 1만
13년 전 조회 1,729
13년 전 조회 2,075
13년 전 조회 4,196
13년 전 조회 1,818
13년 전 조회 2,703
13년 전 조회 4,680
13년 전 조회 2,016
13년 전 조회 1,905
13년 전 조회 6,281
13년 전 조회 2,402
13년 전 조회 1,731
13년 전 조회 3,445
13년 전 조회 3,475
13년 전 조회 2,431
13년 전 조회 3,857
13년 전 조회 7,547
13년 전 조회 3,113
13년 전 조회 1,684
13년 전 조회 2,848
13년 전 조회 2,806
13년 전 조회 3,553
13년 전 조회 1,536
13년 전 조회 2,621
13년 전 조회 1,605
13년 전 조회 2,737
13년 전 조회 3,627
13년 전 조회 2,084
13년 전 조회 4,806
13년 전 조회 1.1만
13년 전 조회 2,087
13년 전 조회 3,472
13년 전 조회 3,067
13년 전 조회 3,900
13년 전 조회 7,013
13년 전 조회 3,551
13년 전 조회 3,965
13년 전 조회 1,939
13년 전 조회 1,709
13년 전 조회 2,814
13년 전 조회 6,809
13년 전 조회 2,430
13년 전 조회 5,653
13년 전 조회 1,755
13년 전 조회 5,053
13년 전 조회 2,231
13년 전 조회 2,035
13년 전 조회 2,496
13년 전 조회 2,246
13년 전 조회 1,475
13년 전 조회 1,458
13년 전 조회 2.1만
13년 전 조회 1,433
13년 전 조회 2,008
13년 전 조회 2,043
13년 전 조회 2,267
13년 전 조회 4,415
13년 전 조회 1,622
13년 전 조회 3,141
13년 전 조회 5,817
13년 전 조회 1,598