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,914
12년 전 조회 2,054
12년 전 조회 4,231
12년 전 조회 3,245
12년 전 조회 2,916
12년 전 조회 2,600
12년 전 조회 2,280
12년 전 조회 2,293
12년 전 조회 2,031
12년 전 조회 3,110
12년 전 조회 2,431
12년 전 조회 2,128
12년 전 조회 3,198
12년 전 조회 2,386
12년 전 조회 2,969
12년 전 조회 4,189
12년 전 조회 1,944
12년 전 조회 2,921
12년 전 조회 1,786
12년 전 조회 2,265
12년 전 조회 2,904
12년 전 조회 2,505
12년 전 조회 5,315
12년 전 조회 3,432
12년 전 조회 3,630
12년 전 조회 1,991
12년 전 조회 9,317
12년 전 조회 4,134
12년 전 조회 2,194
12년 전 조회 2,059
12년 전 조회 3,485
12년 전 조회 6,174
12년 전 조회 4,188
12년 전 조회 2,103
12년 전 조회 1.4만
12년 전 조회 1,978
12년 전 조회 1,408
12년 전 조회 4,777
12년 전 조회 2,256
12년 전 조회 1만
12년 전 조회 1,579
12년 전 조회 2,032
12년 전 조회 4,021
12년 전 조회 1,658
12년 전 조회 2,564
12년 전 조회 4,555
12년 전 조회 1,852
12년 전 조회 1,743
12년 전 조회 6,109
12년 전 조회 2,246
12년 전 조회 1,575
12년 전 조회 3,318
12년 전 조회 3,297
12년 전 조회 2,291
12년 전 조회 3,703
12년 전 조회 7,392
12년 전 조회 2,970
13년 전 조회 1,533
13년 전 조회 2,704
13년 전 조회 2,668
13년 전 조회 3,411
13년 전 조회 1,391
13년 전 조회 2,482
13년 전 조회 1,561
13년 전 조회 2,564
13년 전 조회 3,474
13년 전 조회 2,046
13년 전 조회 4,672
13년 전 조회 1.1만
13년 전 조회 1,933
13년 전 조회 3,309
13년 전 조회 2,926
13년 전 조회 3,856
13년 전 조회 6,842
13년 전 조회 3,495
13년 전 조회 3,814
13년 전 조회 1,774
13년 전 조회 1,547
13년 전 조회 2,658
13년 전 조회 6,662
13년 전 조회 2,278
13년 전 조회 5,514
13년 전 조회 1,698
13년 전 조회 4,909
13년 전 조회 2,074
13년 전 조회 1,884
13년 전 조회 2,444
13년 전 조회 2,072
13년 전 조회 1,335
13년 전 조회 1,310
13년 전 조회 2.1만
13년 전 조회 1,276
13년 전 조회 1,845
13년 전 조회 1,873
13년 전 조회 2,091
13년 전 조회 4,235
13년 전 조회 1,449
13년 전 조회 2,990
13년 전 조회 5,657
13년 전 조회 1,436