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,071
12년 전 조회 2,211
12년 전 조회 4,403
12년 전 조회 3,407
12년 전 조회 3,092
12년 전 조회 2,758
12년 전 조회 2,442
12년 전 조회 2,458
12년 전 조회 2,204
12년 전 조회 3,273
12년 전 조회 2,596
12년 전 조회 2,282
12년 전 조회 3,348
12년 전 조회 2,535
12년 전 조회 3,131
12년 전 조회 4,334
12년 전 조회 2,085
12년 전 조회 3,091
12년 전 조회 1,945
12년 전 조회 2,410
13년 전 조회 3,062
13년 전 조회 2,673
13년 전 조회 5,477
13년 전 조회 3,601
13년 전 조회 3,770
13년 전 조회 2,157
13년 전 조회 9,463
13년 전 조회 4,284
13년 전 조회 2,340
13년 전 조회 2,195
13년 전 조회 3,633
13년 전 조회 6,321
13년 전 조회 4,344
13년 전 조회 2,250
13년 전 조회 1.4만
13년 전 조회 2,130
13년 전 조회 1,537
13년 전 조회 4,806
13년 전 조회 2,311
13년 전 조회 1만
13년 전 조회 1,724
13년 전 조회 2,064
13년 전 조회 4,187
13년 전 조회 1,812
13년 전 조회 2,696
13년 전 조회 4,676
13년 전 조회 2,002
13년 전 조회 1,897
13년 전 조회 6,273
13년 전 조회 2,391
13년 전 조회 1,723
13년 전 조회 3,437
13년 전 조회 3,464
13년 전 조회 2,426
13년 전 조회 3,853
13년 전 조회 7,535
13년 전 조회 3,111
13년 전 조회 1,676
13년 전 조회 2,839
13년 전 조회 2,799
13년 전 조회 3,546
13년 전 조회 1,525
13년 전 조회 2,613
13년 전 조회 1,589
13년 전 조회 2,726
13년 전 조회 3,619
13년 전 조회 2,070
13년 전 조회 4,799
13년 전 조회 1.1만
13년 전 조회 2,078
13년 전 조회 3,462
13년 전 조회 3,057
13년 전 조회 3,889
13년 전 조회 6,999
13년 전 조회 3,535
13년 전 조회 3,956
13년 전 조회 1,932
13년 전 조회 1,698
13년 전 조회 2,808
13년 전 조회 6,801
13년 전 조회 2,423
13년 전 조회 5,648
13년 전 조회 1,738
13년 전 조회 5,049
13년 전 조회 2,222
13년 전 조회 2,029
13년 전 조회 2,477
13년 전 조회 2,241
13년 전 조회 1,469
13년 전 조회 1,452
13년 전 조회 2.1만
13년 전 조회 1,426
13년 전 조회 2,000
13년 전 조회 2,028
13년 전 조회 2,262
13년 전 조회 4,407
13년 전 조회 1,614
13년 전 조회 3,132
13년 전 조회 5,808
13년 전 조회 1,583