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,915
12년 전 조회 2,054
12년 전 조회 4,233
12년 전 조회 3,245
12년 전 조회 2,916
12년 전 조회 2,600
12년 전 조회 2,281
12년 전 조회 2,293
12년 전 조회 2,032
12년 전 조회 3,110
12년 전 조회 2,431
12년 전 조회 2,128
12년 전 조회 3,200
12년 전 조회 2,387
12년 전 조회 2,969
12년 전 조회 4,189
12년 전 조회 1,945
12년 전 조회 2,921
12년 전 조회 1,786
12년 전 조회 2,265
12년 전 조회 2,905
12년 전 조회 2,508
12년 전 조회 5,317
12년 전 조회 3,432
12년 전 조회 3,630
12년 전 조회 1,991
12년 전 조회 9,321
12년 전 조회 4,135
12년 전 조회 2,195
12년 전 조회 2,059
12년 전 조회 3,485
12년 전 조회 6,174
12년 전 조회 4,191
12년 전 조회 2,104
12년 전 조회 1.4만
12년 전 조회 1,978
12년 전 조회 1,408
12년 전 조회 4,777
12년 전 조회 2,256
12년 전 조회 1만
12년 전 조회 1,581
12년 전 조회 2,032
12년 전 조회 4,021
12년 전 조회 1,658
12년 전 조회 2,565
12년 전 조회 4,555
12년 전 조회 1,853
12년 전 조회 1,744
12년 전 조회 6,110
12년 전 조회 2,249
12년 전 조회 1,575
12년 전 조회 3,319
12년 전 조회 3,298
12년 전 조회 2,294
12년 전 조회 3,704
12년 전 조회 7,392
12년 전 조회 2,970
13년 전 조회 1,534
13년 전 조회 2,704
13년 전 조회 2,669
13년 전 조회 3,412
13년 전 조회 1,391
13년 전 조회 2,483
13년 전 조회 1,562
13년 전 조회 2,564
13년 전 조회 3,474
13년 전 조회 2,047
13년 전 조회 4,672
13년 전 조회 1.1만
13년 전 조회 1,935
13년 전 조회 3,309
13년 전 조회 2,927
13년 전 조회 3,856
13년 전 조회 6,843
13년 전 조회 3,495
13년 전 조회 3,814
13년 전 조회 1,774
13년 전 조회 1,549
13년 전 조회 2,660
13년 전 조회 6,662
13년 전 조회 2,278
13년 전 조회 5,515
13년 전 조회 1,698
13년 전 조회 4,910
13년 전 조회 2,074
13년 전 조회 1,885
13년 전 조회 2,444
13년 전 조회 2,073
13년 전 조회 1,336
13년 전 조회 1,311
13년 전 조회 2.1만
13년 전 조회 1,276
13년 전 조회 1,846
13년 전 조회 1,873
13년 전 조회 2,091
13년 전 조회 4,236
13년 전 조회 1,452
13년 전 조회 2,990
13년 전 조회 5,657
13년 전 조회 1,436