펀스몬스터

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

· 2006-08-06 (일) 15:35:25 · 3435
<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건
+
제목 글쓴이 날짜 조회
06-08-18 조회 2,955
06-08-18 조회 3,060
06-08-14 조회 2,486
06-08-13 조회 2,776
06-08-12 조회 3,916
06-08-12 조회 3,053
06-08-11 조회 4,273
06-08-11 조회 4,222
06-08-10 조회 3,308
06-08-10 조회 2,887
06-08-09 조회 3,939
06-08-08 조회 3,946
06-08-08 조회 5,201
06-08-08 조회 3,063
06-08-07 조회 3,796
06-08-06 조회 3,436
06-08-06 조회 4,561
06-08-05 조회 2,513
06-08-05 조회 2,581
06-08-05 조회 2,870
06-08-05 조회 3,344
06-08-05 조회 2,890
06-08-05 조회 2,825
06-08-04 조회 3,200
06-08-04 조회 3,338
06-08-04 조회 6,043
06-08-04 조회 3,440
06-08-04 조회 4,298
06-08-04 조회 3,737
06-08-03 조회 3,523
06-08-01 조회 5,787
06-07-31 조회 3,640
06-07-31 조회 3,477
06-07-30 조회 3,026
06-07-30 조회 2,797
06-07-29 조회 4,493
06-07-29 조회 3,448
06-07-28 조회 7,274
06-07-27 조회 3,207
06-07-26 조회 2,954
06-07-26 조회 3,822
06-07-26 조회 2,872
06-07-26 조회 3,367
06-07-25 조회 3,238
06-07-25 조회 4,665
06-07-25 조회 3,627
06-07-25 조회 3,839
06-07-24 조회 5,496
06-07-24 조회 4,737
06-07-23 조회 3,434
06-07-23 조회 5,513
06-07-22 조회 4,464
06-07-21 조회 5,282
06-07-21 조회 3,119
06-07-21 조회 3,306
06-07-21 조회 3,266
06-07-20 조회 4,422
06-07-20 조회 3,835
06-07-20 조회 4,584
06-07-20 조회 3,809
06-07-20 조회 3,630
06-07-20 조회 3,492
06-07-20 조회 3,325
06-07-20 조회 3,250
06-07-20 조회 5,388
06-07-20 조회 3,795
06-07-20 조회 3,318
06-07-20 조회 3,356
06-07-20 조회 3,977
06-07-19 조회 3,062
06-07-19 조회 4,393
06-07-19 조회 3,941
06-07-19 조회 3,400
06-07-19 조회 2,897
06-07-19 조회 3,331
06-07-19 조회 3,181
06-07-19 조회 3,028
06-07-19 조회 3,577
06-07-19 조회 3,415
06-07-19 조회 4,996
06-07-19 조회 4,860
06-07-19 조회 3,378
06-07-19 조회 4,410
06-07-19 조회 3,104
06-07-19 조회 3,536
06-07-19 조회 3,453
06-07-17 조회 3,453
06-07-17 조회 3,287
06-07-16 조회 3,885
06-07-14 조회 3,928
06-07-14 조회 4,330
06-07-14 조회 4,207
06-07-14 조회 3,814
06-07-13 조회 4,103
06-07-13 조회 4,292
06-07-12 조회 4,033
06-07-11 조회 3,736
06-07-11 조회 4,026
06-07-11 조회 5,661
06-07-11 조회 3,576