펀스몬스터

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

· 19년 전 · 2331
<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,716
19년 전 조회 1,561
19년 전 조회 1,427
19년 전 조회 1,586
19년 전 조회 1,519
19년 전 조회 1,440
19년 전 조회 1,444
19년 전 조회 1,367
19년 전 조회 1,437
19년 전 조회 2,800
19년 전 조회 3,819
19년 전 조회 5,206
19년 전 조회 1,370
19년 전 조회 4,537
19년 전 조회 2,977
19년 전 조회 1,487
19년 전 조회 2,682
19년 전 조회 3,610
19년 전 조회 1,776
19년 전 조회 3,782
19년 전 조회 1,869
19년 전 조회 3,768
19년 전 조회 3,415
19년 전 조회 4,198
19년 전 조회 4,043
19년 전 조회 1,871
19년 전 조회 1,838
19년 전 조회 4,268
19년 전 조회 2,671
19년 전 조회 2,539
19년 전 조회 2,395
19년 전 조회 1,970
19년 전 조회 2,559
19년 전 조회 2,191
19년 전 조회 1,840
19년 전 조회 1,960
19년 전 조회 1,433
19년 전 조회 1,686
19년 전 조회 2,829
19년 전 조회 1,941
19년 전 조회 3,214
19년 전 조회 3,124
19년 전 조회 2,234
19년 전 조회 1,781
19년 전 조회 2,827
19년 전 조회 2,894
19년 전 조회 4,006
19년 전 조회 1,970
19년 전 조회 2,621
19년 전 조회 2,332
19년 전 조회 3,460
19년 전 조회 1,417
19년 전 조회 1,481
19년 전 조회 1,762
19년 전 조회 2,204
19년 전 조회 1,832
19년 전 조회 1,692
19년 전 조회 2,104
19년 전 조회 2,199
19년 전 조회 4,955
19년 전 조회 2,325
19년 전 조회 3,192
19년 전 조회 2,640
19년 전 조회 2,405
19년 전 조회 4,697
19년 전 조회 2,552
19년 전 조회 2,401
19년 전 조회 1,940
19년 전 조회 1,721
19년 전 조회 3,346
19년 전 조회 2,319
19년 전 조회 6,151
19년 전 조회 2,012
19년 전 조회 1,895
19년 전 조회 2,697
19년 전 조회 1,797
19년 전 조회 2,272
19년 전 조회 2,102
19년 전 조회 3,551
19년 전 조회 2,571
19년 전 조회 2,741
19년 전 조회 4,362
19년 전 조회 3,543
19년 전 조회 2,305
19년 전 조회 4,290
19년 전 조회 3,264
19년 전 조회 4,129
19년 전 조회 1,992
19년 전 조회 2,207
19년 전 조회 2,135
19년 전 조회 3,338
19년 전 조회 2,712
19년 전 조회 3,501
19년 전 조회 2,674
19년 전 조회 2,513
19년 전 조회 2,336
19년 전 조회 2,229
19년 전 조회 2,118
19년 전 조회 4,245
19년 전 조회 2,666
🐛 버그신고