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,610
13년 전 조회 2,784
13년 전 조회 4,967
13년 전 조회 3,971
13년 전 조회 3,655
13년 전 조회 3,332
13년 전 조회 3,015
13년 전 조회 2,981
13년 전 조회 2,749
13년 전 조회 3,866
13년 전 조회 3,177
13년 전 조회 2,805
13년 전 조회 3,889
13년 전 조회 3,093
13년 전 조회 3,690
13년 전 조회 4,916
13년 전 조회 2,667
13년 전 조회 3,631
13년 전 조회 2,478
13년 전 조회 2,976
13년 전 조회 3,583
13년 전 조회 3,230
13년 전 조회 6,027
13년 전 조회 4,141
13년 전 조회 4,305
13년 전 조회 2,699
13년 전 조회 1만
13년 전 조회 4,827
13년 전 조회 2,899
13년 전 조회 2,781
13년 전 조회 4,167
13년 전 조회 6,895
13년 전 조회 4,891
13년 전 조회 2,811
13년 전 조회 1.5만
13년 전 조회 2,691
13년 전 조회 2,117
13년 전 조회 5,241
13년 전 조회 2,713
13년 전 조회 1.1만
13년 전 조회 2,297
13년 전 조회 2,551
13년 전 조회 4,738
13년 전 조회 2,345
13년 전 조회 3,256
13년 전 조회 5,168
13년 전 조회 2,547
13년 전 조회 2,448
13년 전 조회 6,834
13년 전 조회 2,927
13년 전 조회 2,242
13년 전 조회 3,987
13년 전 조회 4,024
13년 전 조회 2,995
13년 전 조회 4,433
13년 전 조회 8,091
13년 전 조회 3,647
13년 전 조회 2,267
13년 전 조회 3,397
13년 전 조회 3,351
13년 전 조회 4,109
13년 전 조회 2,120
13년 전 조회 3,218
13년 전 조회 2,090
13년 전 조회 3,278
13년 전 조회 4,190
13년 전 조회 2,534
13년 전 조회 5,395
13년 전 조회 1.2만
13년 전 조회 2,642
13년 전 조회 4,032
13년 전 조회 3,624
13년 전 조회 4,329
13년 전 조회 7,576
13년 전 조회 3,967
13년 전 조회 4,522
13년 전 조회 2,525
13년 전 조회 2,281
13년 전 조회 3,382
13년 전 조회 7,407
13년 전 조회 2,972
13년 전 조회 6,269
13년 전 조회 2,217
13년 전 조회 5,629
13년 전 조회 2,779
13년 전 조회 2,622
13년 전 조회 2,923
13년 전 조회 2,823
13년 전 조회 2,064
13년 전 조회 2,031
13년 전 조회 2.2만
13년 전 조회 2,010
13년 전 조회 2,593
13년 전 조회 2,571
13년 전 조회 2,838
13년 전 조회 5,017
13년 전 조회 2,219
13년 전 조회 3,696
13년 전 조회 6,345
13년 전 조회 2,188