펀스몬스터

textarea에 입력된 길이만큼 게이지로 표현

· 19년 전 · 2342
<script language="JavaScript">
<!--
function textCounter(field,counter,maxlimit,linecounter) {
var fieldWidth = parseInt(field.style.width);
var charcnt = field.value.length;

if(charcnt > maxlimit) {
field.value = field.value.substring(0, maxlimit);
} else {
var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
document.getElementById(counter).style.width = parseInt((fieldWidth*percentage)/100)+"px";
setcolor(document.getElementById(counter),percentage,"background-color");
}
}

function setcolor(obj,percentage,prop){
obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

// 페이지 로드시 명령
textCounter(document.getElementById("maxcharfield"),"progressbar1",200);
//-->
</script>

<!--
textarea에서 onkeydown,onkeyup,onfocus의 명령의 설명

textCounter(this,1,2);

this : 현재 textarea의 name값과 같음
1 : 게이지가 보여질 부분의 id값
2 : textarea에 입력 가능한 최대 글자수

** textarea에서 가로크기는 꼭 style로 해야함 cols는 안됨..
//-->
<textarea style="width:300px" rows="5" name="maxcharfield" onKeyDown="textCounter(this,'progressbar1',200);" onKeyUp="textCounter(this,'progressbar1',200);" onFocus="textCounter(this,'progressbar1',200);">

</textarea>

<!-- 입력 길이를 표시하는 게이지 //-->
<div id="progressbar1" style="width:1px; height:2px; background-color:#DFDFFF;"></div><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
19년 전 조회 1,725
19년 전 조회 1,574
19년 전 조회 1,438
19년 전 조회 1,596
19년 전 조회 1,529
19년 전 조회 1,449
19년 전 조회 1,458
19년 전 조회 1,379
19년 전 조회 1,445
19년 전 조회 2,812
19년 전 조회 3,829
19년 전 조회 5,215
19년 전 조회 1,384
19년 전 조회 4,546
19년 전 조회 2,988
19년 전 조회 1,492
19년 전 조회 2,692
19년 전 조회 3,618
19년 전 조회 1,787
19년 전 조회 3,793
19년 전 조회 1,878
19년 전 조회 3,779
19년 전 조회 3,421
19년 전 조회 4,210
19년 전 조회 4,055
19년 전 조회 1,882
19년 전 조회 1,845
19년 전 조회 4,278
19년 전 조회 2,681
19년 전 조회 2,548
19년 전 조회 2,404
19년 전 조회 1,977
19년 전 조회 2,567
19년 전 조회 2,200
19년 전 조회 1,847
19년 전 조회 1,973
19년 전 조회 1,444
19년 전 조회 1,699
19년 전 조회 2,838
19년 전 조회 1,950
19년 전 조회 3,222
19년 전 조회 3,133
19년 전 조회 2,246
19년 전 조회 1,792
19년 전 조회 2,835
19년 전 조회 2,906
19년 전 조회 4,020
19년 전 조회 1,986
19년 전 조회 2,632
19년 전 조회 2,343
19년 전 조회 3,470
19년 전 조회 1,426
19년 전 조회 1,491
19년 전 조회 1,771
19년 전 조회 2,214
19년 전 조회 1,839
19년 전 조회 1,705
19년 전 조회 2,117
19년 전 조회 2,205
19년 전 조회 4,966
19년 전 조회 2,333
19년 전 조회 3,201
19년 전 조회 2,648
19년 전 조회 2,412
19년 전 조회 4,707
19년 전 조회 2,564
19년 전 조회 2,409
19년 전 조회 1,949
19년 전 조회 1,734
19년 전 조회 3,358
19년 전 조회 2,330
19년 전 조회 6,159
19년 전 조회 2,023
19년 전 조회 1,902
19년 전 조회 2,708
19년 전 조회 1,813
19년 전 조회 2,281
19년 전 조회 2,115
19년 전 조회 3,563
19년 전 조회 2,573
19년 전 조회 2,751
19년 전 조회 4,372
19년 전 조회 3,555
19년 전 조회 2,311
19년 전 조회 4,299
19년 전 조회 3,273
19년 전 조회 4,139
19년 전 조회 2,000
19년 전 조회 2,215
19년 전 조회 2,144
19년 전 조회 3,351
19년 전 조회 2,721
19년 전 조회 3,509
19년 전 조회 2,686
19년 전 조회 2,523
19년 전 조회 2,346
19년 전 조회 2,236
19년 전 조회 2,125
19년 전 조회 4,252
19년 전 조회 2,679