펀스몬스터

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

· 19년 전 · 2378
<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,748
19년 전 조회 1,607
19년 전 조회 1,463
19년 전 조회 1,619
19년 전 조회 1,569
19년 전 조회 1,478
19년 전 조회 1,489
19년 전 조회 1,403
19년 전 조회 1,486
19년 전 조회 2,831
19년 전 조회 3,844
19년 전 조회 5,240
19년 전 조회 1,406
19년 전 조회 4,568
19년 전 조회 3,012
19년 전 조회 1,521
19년 전 조회 2,716
19년 전 조회 3,654
19년 전 조회 1,817
19년 전 조회 3,822
19년 전 조회 1,913
19년 전 조회 3,797
19년 전 조회 3,446
19년 전 조회 4,231
19년 전 조회 4,077
19년 전 조회 1,906
19년 전 조회 1,879
19년 전 조회 4,299
19년 전 조회 2,701
19년 전 조회 2,568
19년 전 조회 2,435
19년 전 조회 2,012
19년 전 조회 2,589
19년 전 조회 2,221
19년 전 조회 1,877
19년 전 조회 2,004
19년 전 조회 1,470
19년 전 조회 1,720
19년 전 조회 2,862
19년 전 조회 1,983
19년 전 조회 3,248
19년 전 조회 3,157
19년 전 조회 2,269
19년 전 조회 1,815
19년 전 조회 2,855
19년 전 조회 2,926
19년 전 조회 4,041
19년 전 조회 2,011
19년 전 조회 2,656
19년 전 조회 2,379
19년 전 조회 3,496
19년 전 조회 1,451
19년 전 조회 1,511
19년 전 조회 1,803
19년 전 조회 2,246
19년 전 조회 1,865
19년 전 조회 1,730
19년 전 조회 2,137
19년 전 조회 2,230
19년 전 조회 4,983
19년 전 조회 2,355
19년 전 조회 3,234
19년 전 조회 2,670
19년 전 조회 2,448
19년 전 조회 4,730
19년 전 조회 2,585
19년 전 조회 2,430
19년 전 조회 1,972
19년 전 조회 1,756
19년 전 조회 3,383
19년 전 조회 2,353
19년 전 조회 6,174
19년 전 조회 2,043
19년 전 조회 1,924
19년 전 조회 2,727
19년 전 조회 1,835
19년 전 조회 2,302
19년 전 조회 2,132
19년 전 조회 3,580
19년 전 조회 2,601
19년 전 조회 2,770
19년 전 조회 4,388
19년 전 조회 3,568
19년 전 조회 2,346
19년 전 조회 4,320
19년 전 조회 3,307
19년 전 조회 4,159
19년 전 조회 2,031
19년 전 조회 2,241
19년 전 조회 2,170
19년 전 조회 3,369
19년 전 조회 2,740
19년 전 조회 3,542
19년 전 조회 2,703
19년 전 조회 2,539
19년 전 조회 2,365
19년 전 조회 2,249
19년 전 조회 2,144
19년 전 조회 4,283
19년 전 조회 2,698