펀스몬스터

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

· 19년 전 · 2330
<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,715
19년 전 조회 1,561
19년 전 조회 1,427
19년 전 조회 1,585
19년 전 조회 1,518
19년 전 조회 1,439
19년 전 조회 1,443
19년 전 조회 1,366
19년 전 조회 1,436
19년 전 조회 2,799
19년 전 조회 3,818
19년 전 조회 5,205
19년 전 조회 1,368
19년 전 조회 4,536
19년 전 조회 2,977
19년 전 조회 1,487
19년 전 조회 2,682
19년 전 조회 3,609
19년 전 조회 1,776
19년 전 조회 3,780
19년 전 조회 1,868
19년 전 조회 3,768
19년 전 조회 3,414
19년 전 조회 4,196
19년 전 조회 4,042
19년 전 조회 1,871
19년 전 조회 1,838
19년 전 조회 4,267
19년 전 조회 2,671
19년 전 조회 2,537
19년 전 조회 2,395
19년 전 조회 1,969
19년 전 조회 2,557
19년 전 조회 2,190
19년 전 조회 1,840
19년 전 조회 1,960
19년 전 조회 1,432
19년 전 조회 1,686
19년 전 조회 2,828
19년 전 조회 1,941
19년 전 조회 3,212
19년 전 조회 3,123
19년 전 조회 2,233
19년 전 조회 1,780
19년 전 조회 2,827
19년 전 조회 2,893
19년 전 조회 4,006
19년 전 조회 1,968
19년 전 조회 2,619
19년 전 조회 2,331
19년 전 조회 3,459
19년 전 조회 1,416
19년 전 조회 1,480
19년 전 조회 1,761
19년 전 조회 2,204
19년 전 조회 1,831
19년 전 조회 1,692
19년 전 조회 2,102
19년 전 조회 2,199
19년 전 조회 4,955
19년 전 조회 2,325
19년 전 조회 3,192
19년 전 조회 2,640
19년 전 조회 2,405
19년 전 조회 4,696
19년 전 조회 2,552
19년 전 조회 2,401
19년 전 조회 1,939
19년 전 조회 1,721
19년 전 조회 3,346
19년 전 조회 2,319
19년 전 조회 6,150
19년 전 조회 2,012
19년 전 조회 1,895
19년 전 조회 2,697
19년 전 조회 1,797
19년 전 조회 2,272
19년 전 조회 2,102
19년 전 조회 3,550
19년 전 조회 2,569
19년 전 조회 2,740
19년 전 조회 4,362
19년 전 조회 3,541
19년 전 조회 2,303
19년 전 조회 4,290
19년 전 조회 3,262
19년 전 조회 4,127
19년 전 조회 1,990
19년 전 조회 2,205
19년 전 조회 2,134
19년 전 조회 3,338
19년 전 조회 2,710
19년 전 조회 3,499
19년 전 조회 2,674
19년 전 조회 2,513
19년 전 조회 2,335
19년 전 조회 2,229
19년 전 조회 2,118
19년 전 조회 4,244
19년 전 조회 2,666
🐛 버그신고