펀스몬스터

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

· 19년 전 · 2596
<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년 전 조회 2,014
19년 전 조회 1,850
19년 전 조회 1,714
19년 전 조회 1,887
19년 전 조회 1,801
19년 전 조회 1,730
19년 전 조회 1,759
19년 전 조회 1,664
19년 전 조회 1,715
19년 전 조회 3,085
19년 전 조회 4,114
19년 전 조회 5,497
19년 전 조회 1,670
19년 전 조회 4,838
19년 전 조회 3,274
19년 전 조회 1,765
19년 전 조회 2,959
19년 전 조회 3,899
19년 전 조회 2,058
19년 전 조회 4,077
19년 전 조회 2,161
19년 전 조회 4,043
19년 전 조회 3,681
19년 전 조회 4,479
19년 전 조회 4,334
19년 전 조회 2,142
19년 전 조회 2,100
19년 전 조회 4,538
19년 전 조회 2,953
19년 전 조회 2,815
19년 전 조회 2,677
19년 전 조회 2,244
19년 전 조회 2,848
19년 전 조회 2,466
19년 전 조회 2,113
19년 전 조회 2,243
19년 전 조회 1,700
19년 전 조회 1,961
19년 전 조회 3,097
19년 전 조회 2,214
19년 전 조회 3,462
19년 전 조회 3,388
19년 전 조회 2,504
19년 전 조회 2,063
19년 전 조회 3,091
19년 전 조회 3,152
19년 전 조회 4,282
19년 전 조회 2,232
19년 전 조회 2,909
19년 전 조회 2,597
19년 전 조회 3,739
19년 전 조회 1,682
19년 전 조회 1,745
19년 전 조회 2,024
19년 전 조회 2,472
19년 전 조회 2,088
19년 전 조회 1,970
19년 전 조회 2,368
19년 전 조회 2,457
19년 전 조회 5,216
19년 전 조회 2,597
19년 전 조회 3,463
19년 전 조회 2,918
19년 전 조회 2,674
19년 전 조회 4,964
19년 전 조회 2,821
19년 전 조회 2,665
19년 전 조회 2,227
19년 전 조회 2,003
19년 전 조회 3,627
19년 전 조회 2,584
19년 전 조회 6,427
19년 전 조회 2,307
19년 전 조회 2,164
19년 전 조회 2,982
19년 전 조회 2,080
19년 전 조회 2,526
19년 전 조회 2,365
19년 전 조회 3,835
19년 전 조회 2,828
19년 전 조회 3,028
19년 전 조회 4,630
19년 전 조회 3,826
19년 전 조회 2,566
19년 전 조회 4,566
19년 전 조회 3,544
19년 전 조회 4,418
19년 전 조회 2,274
19년 전 조회 2,487
19년 전 조회 2,415
19년 전 조회 3,615
19년 전 조회 2,997
19년 전 조회 3,765
19년 전 조회 2,964
19년 전 조회 2,777
19년 전 조회 2,611
19년 전 조회 2,501
19년 전 조회 2,407
19년 전 조회 4,527
19년 전 조회 2,945