펀스몬스터

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

· 2006-08-06 (일) 15:35:25 · 3403
<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,188건
+
제목 글쓴이 날짜 조회
06-08-18 조회 3,254
06-08-18 조회 2,921
06-08-18 조회 3,029
06-08-14 조회 2,467
06-08-13 조회 2,751
06-08-12 조회 3,887
06-08-12 조회 3,017
06-08-11 조회 4,241
06-08-11 조회 4,188
06-08-10 조회 3,285
06-08-10 조회 2,864
06-08-09 조회 3,915
06-08-08 조회 3,919
06-08-08 조회 5,167
06-08-08 조회 3,032
06-08-07 조회 3,774
06-08-06 조회 3,404
06-08-06 조회 4,529
06-08-05 조회 2,480
06-08-05 조회 2,554
06-08-05 조회 2,842
06-08-05 조회 3,315
06-08-05 조회 2,868
06-08-05 조회 2,797
06-08-04 조회 3,177
06-08-04 조회 3,313
06-08-04 조회 6,011
06-08-04 조회 3,414
06-08-04 조회 4,269
06-08-04 조회 3,718
06-08-03 조회 3,496
06-08-01 조회 5,760
06-07-31 조회 3,608
06-07-31 조회 3,448
06-07-30 조회 2,993
06-07-30 조회 2,774
06-07-29 조회 4,467
06-07-29 조회 3,424
06-07-28 조회 7,239
06-07-27 조회 3,181
06-07-26 조회 2,929
06-07-26 조회 3,799
06-07-26 조회 2,848
06-07-26 조회 3,338
06-07-25 조회 3,208
06-07-25 조회 4,633
06-07-25 조회 3,594
06-07-25 조회 3,806
06-07-24 조회 5,469
06-07-24 조회 4,701
06-07-23 조회 3,399
06-07-23 조회 5,478
06-07-22 조회 4,434
06-07-21 조회 5,243
06-07-21 조회 3,080
06-07-21 조회 3,278
06-07-21 조회 3,240
06-07-20 조회 4,391
06-07-20 조회 3,801
06-07-20 조회 4,549
06-07-20 조회 3,776
06-07-20 조회 3,607
06-07-20 조회 3,465
06-07-20 조회 3,302
06-07-20 조회 3,227
06-07-20 조회 5,362
06-07-20 조회 3,763
06-07-20 조회 3,287
06-07-20 조회 3,322
06-07-20 조회 3,948
06-07-19 조회 3,034
06-07-19 조회 4,369
06-07-19 조회 3,918
06-07-19 조회 3,379
06-07-19 조회 2,873
06-07-19 조회 3,299
06-07-19 조회 3,135
06-07-19 조회 2,994
06-07-19 조회 3,544
06-07-19 조회 3,389
06-07-19 조회 4,963
06-07-19 조회 4,828
06-07-19 조회 3,346
06-07-19 조회 4,369
06-07-19 조회 3,059
06-07-19 조회 3,493
06-07-19 조회 3,410
06-07-17 조회 3,421
06-07-17 조회 3,253
06-07-16 조회 3,851
06-07-14 조회 3,901
06-07-14 조회 4,306
06-07-14 조회 4,180
06-07-14 조회 3,781
06-07-13 조회 4,067
06-07-13 조회 4,252
06-07-12 조회 3,993
06-07-11 조회 3,697
06-07-11 조회 3,984
06-07-11 조회 5,628