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,419
13년 전 조회 2,615
13년 전 조회 4,774
13년 전 조회 3,769
13년 전 조회 3,472
13년 전 조회 3,118
13년 전 조회 2,815
13년 전 조회 2,801
13년 전 조회 2,531
13년 전 조회 3,657
13년 전 조회 2,955
13년 전 조회 2,608
13년 전 조회 3,673
13년 전 조회 2,894
13년 전 조회 3,489
13년 전 조회 4,720
13년 전 조회 2,482
13년 전 조회 3,463
13년 전 조회 2,300
13년 전 조회 2,757
13년 전 조회 3,397
13년 전 조회 3,040
13년 전 조회 5,833
13년 전 조회 3,947
13년 전 조회 4,136
13년 전 조회 2,480
13년 전 조회 9,811
13년 전 조회 4,652
13년 전 조회 2,708
13년 전 조회 2,579
13년 전 조회 3,969
13년 전 조회 6,689
13년 전 조회 4,704
13년 전 조회 2,633
13년 전 조회 1.5만
13년 전 조회 2,493
13년 전 조회 1,921
13년 전 조회 5,147
13년 전 조회 2,635
13년 전 조회 1.1만
13년 전 조회 2,098
13년 전 조회 2,455
13년 전 조회 4,544
13년 전 조회 2,157
13년 전 조회 3,055
13년 전 조회 4,981
13년 전 조회 2,364
13년 전 조회 2,256
13년 전 조회 6,625
13년 전 조회 2,728
13년 전 조회 2,034
13년 전 조회 3,818
13년 전 조회 3,827
13년 전 조회 2,787
13년 전 조회 4,230
13년 전 조회 7,895
13년 전 조회 3,458
13년 전 조회 2,064
13년 전 조회 3,213
13년 전 조회 3,154
13년 전 조회 3,928
13년 전 조회 1,913
13년 전 조회 3,010
13년 전 조회 2,002
13년 전 조회 3,089
13년 전 조회 3,998
13년 전 조회 2,434
13년 전 조회 5,193
13년 전 조회 1.1만
13년 전 조회 2,453
13년 전 조회 3,808
13년 전 조회 3,417
13년 전 조회 4,233
13년 전 조회 7,344
13년 전 조회 3,872
13년 전 조회 4,316
13년 전 조회 2,302
13년 전 조회 2,075
13년 전 조회 3,168
13년 전 조회 7,179
13년 전 조회 2,764
13년 전 조회 6,052
13년 전 조회 2,134
13년 전 조회 5,418
13년 전 조회 2,575
13년 전 조회 2,424
13년 전 조회 2,839
13년 전 조회 2,602
13년 전 조회 1,848
13년 전 조회 1,838
13년 전 조회 2.2만
13년 전 조회 1,794
13년 전 조회 2,365
13년 전 조회 2,386
13년 전 조회 2,637
13년 전 조회 4,782
13년 전 조회 2,011
13년 전 조회 3,494
13년 전 조회 6,148
13년 전 조회 1,997