펀스몬스터

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

· 19년 전 · 2403
<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,793
19년 전 조회 1,645
19년 전 조회 1,502
19년 전 조회 1,662
19년 전 조회 1,607
19년 전 조회 1,514
19년 전 조회 1,522
19년 전 조회 1,441
19년 전 조회 1,515
19년 전 조회 2,871
19년 전 조회 3,886
19년 전 조회 5,284
19년 전 조회 1,444
19년 전 조회 4,610
19년 전 조회 3,049
19년 전 조회 1,553
19년 전 조회 2,755
19년 전 조회 3,690
19년 전 조회 1,853
19년 전 조회 3,863
19년 전 조회 1,944
19년 전 조회 3,843
19년 전 조회 3,489
19년 전 조회 4,270
19년 전 조회 4,115
19년 전 조회 1,945
19년 전 조회 1,911
19년 전 조회 4,329
19년 전 조회 2,741
19년 전 조회 2,607
19년 전 조회 2,459
19년 전 조회 2,045
19년 전 조회 2,632
19년 전 조회 2,260
19년 전 조회 1,909
19년 전 조회 2,043
19년 전 조회 1,503
19년 전 조회 1,757
19년 전 조회 2,893
19년 전 조회 2,012
19년 전 조회 3,279
19년 전 조회 3,193
19년 전 조회 2,300
19년 전 조회 1,840
19년 전 조회 2,880
19년 전 조회 2,963
19년 전 조회 4,074
19년 전 조회 2,048
19년 전 조회 2,688
19년 전 조회 2,404
19년 전 조회 3,527
19년 전 조회 1,483
19년 전 조회 1,539
19년 전 조회 1,836
19년 전 조회 2,278
19년 전 조회 1,898
19년 전 조회 1,770
19년 전 조회 2,178
19년 전 조회 2,264
19년 전 조회 5,021
19년 전 조회 2,390
19년 전 조회 3,264
19년 전 조회 2,712
19년 전 조회 2,480
19년 전 조회 4,760
19년 전 조회 2,616
19년 전 조회 2,467
19년 전 조회 2,012
19년 전 조회 1,798
19년 전 조회 3,411
19년 전 조회 2,391
19년 전 조회 6,210
19년 전 조회 2,084
19년 전 조회 1,970
19년 전 조회 2,771
19년 전 조회 1,869
19년 전 조회 2,342
19년 전 조회 2,170
19년 전 조회 3,611
19년 전 조회 2,631
19년 전 조회 2,810
19년 전 조회 4,420
19년 전 조회 3,598
19년 전 조회 2,381
19년 전 조회 4,353
19년 전 조회 3,342
19년 전 조회 4,190
19년 전 조회 2,066
19년 전 조회 2,271
19년 전 조회 2,199
19년 전 조회 3,406
19년 전 조회 2,774
19년 전 조회 3,569
19년 전 조회 2,732
19년 전 조회 2,577
19년 전 조회 2,400
19년 전 조회 2,287
19년 전 조회 2,176
19년 전 조회 4,314
19년 전 조회 2,731