펀스몬스터

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

· 19년 전 · 2346
<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,730
19년 전 조회 1,579
19년 전 조회 1,441
19년 전 조회 1,601
19년 전 조회 1,534
19년 전 조회 1,454
19년 전 조회 1,465
19년 전 조회 1,385
19년 전 조회 1,450
19년 전 조회 2,813
19년 전 조회 3,832
19년 전 조회 5,221
19년 전 조회 1,390
19년 전 조회 4,550
19년 전 조회 2,991
19년 전 조회 1,500
19년 전 조회 2,696
19년 전 조회 3,623
19년 전 조회 1,796
19년 전 조회 3,800
19년 전 조회 1,882
19년 전 조회 3,782
19년 전 조회 3,428
19년 전 조회 4,218
19년 전 조회 4,062
19년 전 조회 1,884
19년 전 조회 1,850
19년 전 조회 4,282
19년 전 조회 2,684
19년 전 조회 2,551
19년 전 조회 2,411
19년 전 조회 1,983
19년 전 조회 2,571
19년 전 조회 2,206
19년 전 조회 1,852
19년 전 조회 1,982
19년 전 조회 1,449
19년 전 조회 1,703
19년 전 조회 2,844
19년 전 조회 1,953
19년 전 조회 3,229
19년 전 조회 3,139
19년 전 조회 2,252
19년 전 조회 1,798
19년 전 조회 2,840
19년 전 조회 2,909
19년 전 조회 4,026
19년 전 조회 1,992
19년 전 조회 2,639
19년 전 조회 2,347
19년 전 조회 3,474
19년 전 조회 1,430
19년 전 조회 1,497
19년 전 조회 1,777
19년 전 조회 2,219
19년 전 조회 1,840
19년 전 조회 1,708
19년 전 조회 2,122
19년 전 조회 2,214
19년 전 조회 4,971
19년 전 조회 2,338
19년 전 조회 3,205
19년 전 조회 2,651
19년 전 조회 2,419
19년 전 조회 4,713
19년 전 조회 2,566
19년 전 조회 2,413
19년 전 조회 1,952
19년 전 조회 1,737
19년 전 조회 3,365
19년 전 조회 2,335
19년 전 조회 6,163
19년 전 조회 2,028
19년 전 조회 1,907
19년 전 조회 2,712
19년 전 조회 1,818
19년 전 조회 2,284
19년 전 조회 2,117
19년 전 조회 3,568
19년 전 조회 2,580
19년 전 조회 2,755
19년 전 조회 4,378
19년 전 조회 3,559
19년 전 조회 2,317
19년 전 조회 4,304
19년 전 조회 3,278
19년 전 조회 4,144
19년 전 조회 2,003
19년 전 조회 2,219
19년 전 조회 2,148
19년 전 조회 3,357
19년 전 조회 2,724
19년 전 조회 3,516
19년 전 조회 2,693
19년 전 조회 2,530
19년 전 조회 2,352
19년 전 조회 2,243
19년 전 조회 2,130
19년 전 조회 4,260
19년 전 조회 2,681