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,465
13년 전 조회 2,663
13년 전 조회 4,836
13년 전 조회 3,819
13년 전 조회 3,521
13년 전 조회 3,189
13년 전 조회 2,863
13년 전 조회 2,857
13년 전 조회 2,592
13년 전 조회 3,727
13년 전 조회 3,025
13년 전 조회 2,660
13년 전 조회 3,729
13년 전 조회 2,958
13년 전 조회 3,536
13년 전 조회 4,778
13년 전 조회 2,539
13년 전 조회 3,513
13년 전 조회 2,355
13년 전 조회 2,818
13년 전 조회 3,444
13년 전 조회 3,087
13년 전 조회 5,891
13년 전 조회 3,990
13년 전 조회 4,179
13년 전 조회 2,537
13년 전 조회 9,875
13년 전 조회 4,703
13년 전 조회 2,762
13년 전 조회 2,638
13년 전 조회 4,025
13년 전 조회 6,745
13년 전 조회 4,754
13년 전 조회 2,682
13년 전 조회 1.5만
13년 전 조회 2,547
13년 전 조회 1,968
13년 전 조회 5,160
13년 전 조회 2,649
13년 전 조회 1.1만
13년 전 조회 2,153
13년 전 조회 2,476
13년 전 조회 4,590
13년 전 조회 2,202
13년 전 조회 3,102
13년 전 조회 5,028
13년 전 조회 2,410
13년 전 조회 2,307
13년 전 조회 6,688
13년 전 조회 2,780
13년 전 조회 2,097
13년 전 조회 3,862
13년 전 조회 3,879
13년 전 조회 2,850
13년 전 조회 4,277
13년 전 조회 7,947
13년 전 조회 3,509
13년 전 조회 2,120
13년 전 조회 3,261
13년 전 조회 3,208
13년 전 조회 3,978
13년 전 조회 1,972
13년 전 조회 3,075
13년 전 조회 2,020
13년 전 조회 3,133
13년 전 조회 4,053
13년 전 조회 2,450
13년 전 조회 5,262
13년 전 조회 1.1만
13년 전 조회 2,510
13년 전 조회 3,857
13년 전 조회 3,488
13년 전 조회 4,254
13년 전 조회 7,398
13년 전 조회 3,886
13년 전 조회 4,375
13년 전 조회 2,367
13년 전 조회 2,134
13년 전 조회 3,227
13년 전 조회 7,239
13년 전 조회 2,821
13년 전 조회 6,112
13년 전 조회 2,144
13년 전 조회 5,475
13년 전 조회 2,638
13년 전 조회 2,483
13년 전 조회 2,857
13년 전 조회 2,662
13년 전 조회 1,915
13년 전 조회 1,902
13년 전 조회 2.2만
13년 전 조회 1,845
13년 전 조회 2,438
13년 전 조회 2,440
13년 전 조회 2,687
13년 전 조회 4,842
13년 전 조회 2,073
13년 전 조회 3,549
13년 전 조회 6,191
13년 전 조회 2,047