펀스몬스터

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

· 2006-08-06 (일) 15:35:25 · 3415
<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-09-21 조회 3,693
06-09-21 조회 3,012
06-09-21 조회 3,243
06-09-21 조회 4,472
06-09-21 조회 3,126
06-09-21 조회 3,605
06-09-21 조회 3,703
06-09-21 조회 3,848
06-09-21 조회 4,061
06-09-21 조회 3,764
06-09-21 조회 4,239
06-09-21 조회 4,010
06-09-21 조회 4,674
06-09-20 조회 3,074
06-09-19 조회 3,939
06-09-18 조회 3,599
06-09-15 조회 3,203
06-09-15 조회 3,598
06-09-15 조회 3,036
06-09-15 조회 6,648
06-09-15 조회 3,448
06-09-13 조회 5,389
06-09-13 조회 3,508
06-09-11 조회 3,026
06-09-11 조회 3,719
06-09-11 조회 3,458
06-09-11 조회 3,677
06-09-11 조회 3,305
06-09-11 조회 5,033
06-09-11 조회 4,531
06-09-11 조회 3,335
06-09-11 조회 3,265
06-09-10 조회 3,155
06-09-06 조회 3,155
06-09-05 조회 5,494
06-09-04 조회 4,478
06-09-04 조회 3,899
06-09-03 조회 4,459
06-09-02 조회 4,098
06-09-02 조회 3,956
06-09-02 조회 3,548
06-09-01 조회 3,308
06-09-01 조회 3,623
06-09-01 조회 4,187
06-08-31 조회 3,188
06-08-31 조회 4,243
06-08-28 조회 4,379
06-08-27 조회 4,006
06-08-27 조회 3,097
06-08-27 조회 2,804
06-08-27 조회 3,432
06-08-27 조회 3,401
06-08-27 조회 2,735
06-08-27 조회 2,762
06-08-27 조회 2,665
06-08-27 조회 3,160
06-08-27 조회 2,731
06-08-27 조회 3,283
06-08-27 조회 3,049
06-08-27 조회 2,928
06-08-27 조회 2,747
06-08-27 조회 2,936
06-08-27 조회 3,006
06-08-27 조회 3,030
06-08-27 조회 3,770
06-08-27 조회 6,424
06-08-27 조회 2,829
06-08-27 조회 2,676
06-08-27 조회 2,500
06-08-27 조회 2,714
06-08-27 조회 2,642
06-08-27 조회 2,575
06-08-27 조회 2,590
06-08-27 조회 2,497
06-08-27 조회 2,566
06-08-27 조회 4,020
06-08-27 조회 4,982
06-08-26 조회 6,344
06-08-26 조회 2,501
06-08-26 조회 5,660
06-08-25 조회 4,107
06-08-25 조회 2,648
06-08-24 조회 3,822
06-08-24 조회 4,753
06-08-24 조회 2,895
06-08-23 조회 4,944
06-08-23 조회 3,016
06-08-23 조회 4,863
06-08-23 조회 4,540
06-08-23 조회 5,274
06-08-23 조회 5,175
06-08-22 조회 2,960
06-08-22 조회 2,958
06-08-21 조회 5,419
06-08-20 조회 3,818
06-08-20 조회 3,697
06-08-19 조회 3,529
06-08-19 조회 3,093
06-08-18 조회 3,731
06-08-18 조회 3,265