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개

댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
13년 전 조회 3,446
13년 전 조회 2,639
13년 전 조회 4,815
13년 전 조회 3,800
13년 전 조회 3,493
13년 전 조회 3,157
13년 전 조회 2,845
13년 전 조회 2,833
13년 전 조회 2,561
13년 전 조회 3,696
13년 전 조회 2,992
13년 전 조회 2,624
13년 전 조회 3,700
13년 전 조회 2,920
13년 전 조회 3,513
13년 전 조회 4,744
13년 전 조회 2,517
13년 전 조회 3,485
13년 전 조회 2,330
13년 전 조회 2,788
13년 전 조회 3,421
13년 전 조회 3,062
13년 전 조회 5,858
13년 전 조회 3,968
13년 전 조회 4,157
13년 전 조회 2,509
13년 전 조회 9,846
13년 전 조회 4,674
13년 전 조회 2,737
13년 전 조회 2,610
13년 전 조회 3,994
13년 전 조회 6,716
13년 전 조회 4,730
13년 전 조회 2,660
13년 전 조회 1.5만
13년 전 조회 2,519
13년 전 조회 1,952
13년 전 조회 5,150
13년 전 조회 2,641
13년 전 조회 1.1만
13년 전 조회 2,121
13년 전 조회 2,462
13년 전 조회 4,571
13년 전 조회 2,184
13년 전 조회 3,078
13년 전 조회 5,008
13년 전 조회 2,388
13년 전 조회 2,283
13년 전 조회 6,657
13년 전 조회 2,751
13년 전 조회 2,061
13년 전 조회 3,839
13년 전 조회 3,851
13년 전 조회 2,822
13년 전 조회 4,256
13년 전 조회 7,925
13년 전 조회 3,482
13년 전 조회 2,097
13년 전 조회 3,235
13년 전 조회 3,177
13년 전 조회 3,955
13년 전 조회 1,941
13년 전 조회 3,049
13년 전 조회 2,011
13년 전 조회 3,117
13년 전 조회 4,029
13년 전 조회 2,439
13년 전 조회 5,228
13년 전 조회 1.1만
13년 전 조회 2,486
13년 전 조회 3,831
13년 전 조회 3,455
13년 전 조회 4,244
13년 전 조회 7,368
13년 전 조회 3,875
13년 전 조회 4,349
13년 전 조회 2,336
13년 전 조회 2,107
13년 전 조회 3,200
13년 전 조회 7,208
13년 전 조회 2,795
13년 전 조회 6,093
13년 전 조회 2,138
13년 전 조회 5,446
13년 전 조회 2,609
13년 전 조회 2,460
13년 전 조회 2,845
13년 전 조회 2,641
13년 전 조회 1,893
13년 전 조회 1,878
13년 전 조회 2.2만
13년 전 조회 1,821
13년 전 조회 2,407
13년 전 조회 2,416
13년 전 조회 2,666
13년 전 조회 4,818
13년 전 조회 2,047
13년 전 조회 3,522
13년 전 조회 6,178
13년 전 조회 2,029