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,035
12년 전 조회 2,179
12년 전 조회 4,363
12년 전 조회 3,359
12년 전 조회 3,054
12년 전 조회 2,715
12년 전 조회 2,406
12년 전 조회 2,423
12년 전 조회 2,158
12년 전 조회 3,237
12년 전 조회 2,548
12년 전 조회 2,244
12년 전 조회 3,314
12년 전 조회 2,494
12년 전 조회 3,091
12년 전 조회 4,298
12년 전 조회 2,048
12년 전 조회 3,054
12년 전 조회 1,899
12년 전 조회 2,377
12년 전 조회 3,014
12년 전 조회 2,632
12년 전 조회 5,440
12년 전 조회 3,562
12년 전 조회 3,736
13년 전 조회 2,120
13년 전 조회 9,423
13년 전 조회 4,239
13년 전 조회 2,301
13년 전 조회 2,164
13년 전 조회 3,595
13년 전 조회 6,289
13년 전 조회 4,301
13년 전 조회 2,214
13년 전 조회 1.4만
13년 전 조회 2,095
13년 전 조회 1,499
13년 전 조회 4,798
13년 전 조회 2,298
13년 전 조회 1만
13년 전 조회 1,690
13년 전 조회 2,055
13년 전 조회 4,152
13년 전 조회 1,776
13년 전 조회 2,662
13년 전 조회 4,644
13년 전 조회 1,975
13년 전 조회 1,860
13년 전 조회 6,221
13년 전 조회 2,353
13년 전 조회 1,683
13년 전 조회 3,398
13년 전 조회 3,417
13년 전 조회 2,393
13년 전 조회 3,813
13년 전 조회 7,500
13년 전 조회 3,072
13년 전 조회 1,636
13년 전 조회 2,800
13년 전 조회 2,763
13년 전 조회 3,510
13년 전 조회 1,487
13년 전 조회 2,582
13년 전 조회 1,576
13년 전 조회 2,698
13년 전 조회 3,573
13년 전 조회 2,058
13년 전 조회 4,756
13년 전 조회 1.1만
13년 전 조회 2,035
13년 전 조회 3,418
13년 전 조회 3,021
13년 전 조회 3,875
13년 전 조회 6,958
13년 전 조회 3,528
13년 전 조회 3,914
13년 전 조회 1,902
13년 전 조회 1,659
13년 전 조회 2,763
13년 전 조회 6,764
13년 전 조회 2,378
13년 전 조회 5,612
13년 전 조회 1,725
13년 전 조회 5,009
13년 전 조회 2,183
13년 전 조회 1,993
13년 전 조회 2,468
13년 전 조회 2,191
13년 전 조회 1,432
13년 전 조회 1,413
13년 전 조회 2.1만
13년 전 조회 1,392
13년 전 조회 1,946
13년 전 조회 1,990
13년 전 조회 2,215
13년 전 조회 4,371
13년 전 조회 1,573
13년 전 조회 3,101
13년 전 조회 5,766
13년 전 조회 1,548