펀스몬스터

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

· 2006-08-06 (일) 15:35:25 · 3430
<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>
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,187건
+
제목 글쓴이 날짜 조회
07-01-25 조회 4,159
07-01-25 조회 5,164
07-01-24 조회 3,936
07-01-21 조회 4,772
07-01-21 조회 3,307
07-01-19 조회 6,703
07-01-19 조회 3,106
07-01-19 조회 7,413
07-01-19 조회 4,147
07-01-19 조회 7,347
07-01-19 조회 8,154
07-01-16 조회 5,069
07-01-13 조회 3,639
07-01-10 조회 3,485
07-01-09 조회 8,264
07-01-09 조회 3,719
07-01-09 조회 5,295
07-01-08 조회 6,677
07-01-08 조회 4,127
07-01-07 조회 3,037
07-01-06 조회 2,883
07-01-02 조회 2,814
07-01-02 조회 3,080
07-01-01 조회 3,088
07-01-01 조회 3,114
06-12-29 조회 3,049
06-12-29 조회 3,904
06-12-27 조회 3,687
06-12-26 조회 4,789
06-12-21 조회 3,891
06-12-20 조회 3,884
06-12-18 조회 4,745
06-12-16 조회 5,962
06-12-15 조회 4,314
06-12-15 조회 4,114
06-12-15 조회 4,715
06-12-15 조회 7,586
06-12-15 조회 3,465
06-12-15 조회 3,300
06-12-15 조회 3,208
06-12-15 조회 3,324
06-12-15 조회 4,508
06-12-15 조회 3,586
06-12-15 조회 3,253
06-12-15 조회 3,000
06-12-15 조회 3,407
06-12-15 조회 4,670
06-12-15 조회 4,544
06-12-15 조회 3,270
06-12-15 조회 2,792
06-12-15 조회 4,560
06-12-15 조회 3,428
06-12-15 조회 2,974
06-12-15 조회 4,139
06-12-15 조회 3,266
06-12-15 조회 3,128
06-12-15 조회 3,133
06-12-15 조회 3,101
06-12-15 조회 3,561
06-12-15 조회 3,920
06-12-15 조회 3,075
06-12-15 조회 2,817
06-12-15 조회 2,842
06-12-15 조회 2,703
06-12-15 조회 4,467
06-12-15 조회 4,192
06-12-15 조회 2,937
06-12-15 조회 4,666
06-12-15 조회 3,104
06-12-15 조회 2,713
06-12-15 조회 3,223
06-12-15 조회 3,378
06-12-15 조회 2,882
06-12-15 조회 3,639
06-12-15 조회 3,320
06-12-15 조회 2,895
06-12-15 조회 3,039
06-12-15 조회 3,333
06-12-15 조회 3,087
06-12-13 조회 2,826
06-12-13 조회 2,912
06-12-13 조회 4,406
06-12-12 조회 3,381
06-12-12 조회 3,113
06-12-12 조회 5,651
06-12-12 조회 6,303
06-12-11 조회 4,505
06-12-10 조회 4,157
06-12-07 조회 4,776
06-12-07 조회 3,353
06-12-07 조회 3,680
06-12-07 조회 3,957
06-12-07 조회 4,055
06-12-07 조회 3,625
06-12-04 조회 2,903
06-12-04 조회 4,713
06-11-30 조회 3,225
06-11-30 조회 3,710
06-11-30 조회 3,751
06-11-28 조회 4,223