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,394
12년 전 조회 1,544
12년 전 조회 3,731
12년 전 조회 2,755
12년 전 조회 2,464
12년 전 조회 2,095
12년 전 조회 1,780
12년 전 조회 1,779
12년 전 조회 1,527
12년 전 조회 2,654
12년 전 조회 1,927
12년 전 조회 1,606
12년 전 조회 2,690
12년 전 조회 1,865
12년 전 조회 2,479
12년 전 조회 3,701
12년 전 조회 1,490
12년 전 조회 2,445
12년 전 조회 1,298
12년 전 조회 1,791
12년 전 조회 2,365
12년 전 조회 1,999
12년 전 조회 4,812
12년 전 조회 2,915
12년 전 조회 3,095
12년 전 조회 1,458
12년 전 조회 8,776
12년 전 조회 3,604
12년 전 조회 1,673
12년 전 조회 1,542
12년 전 조회 2,931
12년 전 조회 5,614
12년 전 조회 3,656
12년 전 조회 1,593
12년 전 조회 1.4만
12년 전 조회 1,460
12년 전 조회 866
12년 전 조회 4,178
12년 전 조회 1,676
12년 전 조회 9,568
12년 전 조회 1,047
12년 전 조회 1,485
12년 전 조회 3,449
12년 전 조회 1,106
12년 전 조회 2,006
12년 전 조회 3,909
12년 전 조회 1,318
12년 전 조회 1,221
12년 전 조회 5,547
12년 전 조회 1,683
12년 전 조회 1,016
12년 전 조회 2,805
12년 전 조회 2,737
12년 전 조회 1,754
12년 전 조회 3,185
12년 전 조회 6,808
12년 전 조회 2,387
12년 전 조회 989
12년 전 조회 2,149
12년 전 조회 2,075
12년 전 조회 2,853
12년 전 조회 848
12년 전 조회 1,935
12년 전 조회 1,021
12년 전 조회 2,000
12년 전 조회 2,932
12년 전 조회 1,490
12년 전 조회 4,128
12년 전 조회 1만
12년 전 조회 1,354
12년 전 조회 2,700
12년 전 조회 2,377
12년 전 조회 3,239
12년 전 조회 6,259
12년 전 조회 2,869
12년 전 조회 3,214
12년 전 조회 1,219
13년 전 조회 1,008
13년 전 조회 2,101
13년 전 조회 6,112
13년 전 조회 1,717
13년 전 조회 4,952
13년 전 조회 1,174
13년 전 조회 4,344
13년 전 조회 1,482
13년 전 조회 1,334
13년 전 조회 1,917
13년 전 조회 1,555
13년 전 조회 807
13년 전 조회 786
13년 전 조회 2.1만
13년 전 조회 745
13년 전 조회 1,325
13년 전 조회 1,323
13년 전 조회 1,549
13년 전 조회 3,716
13년 전 조회 960
13년 전 조회 2,445
13년 전 조회 5,130
13년 전 조회 904