펀스몬스터

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

· 19년 전 · 2344
<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,728
19년 전 조회 1,576
19년 전 조회 1,440
19년 전 조회 1,599
19년 전 조회 1,533
19년 전 조회 1,452
19년 전 조회 1,460
19년 전 조회 1,385
19년 전 조회 1,448
19년 전 조회 2,813
19년 전 조회 3,831
19년 전 조회 5,217
19년 전 조회 1,385
19년 전 조회 4,549
19년 전 조회 2,989
19년 전 조회 1,496
19년 전 조회 2,694
19년 전 조회 3,621
19년 전 조회 1,791
19년 전 조회 3,796
19년 전 조회 1,880
19년 전 조회 3,780
19년 전 조회 3,424
19년 전 조회 4,213
19년 전 조회 4,058
19년 전 조회 1,883
19년 전 조회 1,848
19년 전 조회 4,281
19년 전 조회 2,682
19년 전 조회 2,550
19년 전 조회 2,410
19년 전 조회 1,982
19년 전 조회 2,569
19년 전 조회 2,204
19년 전 조회 1,850
19년 전 조회 1,977
19년 전 조회 1,448
19년 전 조회 1,701
19년 전 조회 2,841
19년 전 조회 1,953
19년 전 조회 3,225
19년 전 조회 3,138
19년 전 조회 2,249
19년 전 조회 1,797
19년 전 조회 2,837
19년 전 조회 2,907
19년 전 조회 4,024
19년 전 조회 1,987
19년 전 조회 2,636
19년 전 조회 2,345
19년 전 조회 3,473
19년 전 조회 1,426
19년 전 조회 1,495
19년 전 조회 1,775
19년 전 조회 2,217
19년 전 조회 1,840
19년 전 조회 1,705
19년 전 조회 2,119
19년 전 조회 2,211
19년 전 조회 4,970
19년 전 조회 2,337
19년 전 조회 3,203
19년 전 조회 2,650
19년 전 조회 2,416
19년 전 조회 4,710
19년 전 조회 2,565
19년 전 조회 2,413
19년 전 조회 1,952
19년 전 조회 1,735
19년 전 조회 3,359
19년 전 조회 2,332
19년 전 조회 6,161
19년 전 조회 2,024
19년 전 조회 1,905
19년 전 조회 2,711
19년 전 조회 1,816
19년 전 조회 2,282
19년 전 조회 2,117
19년 전 조회 3,566
19년 전 조회 2,578
19년 전 조회 2,755
19년 전 조회 4,374
19년 전 조회 3,557
19년 전 조회 2,316
19년 전 조회 4,302
19년 전 조회 3,277
19년 전 조회 4,141
19년 전 조회 2,002
19년 전 조회 2,217
19년 전 조회 2,146
19년 전 조회 3,355
19년 전 조회 2,723
19년 전 조회 3,511
19년 전 조회 2,691
19년 전 조회 2,527
19년 전 조회 2,349
19년 전 조회 2,241
19년 전 조회 2,129
19년 전 조회 4,259
19년 전 조회 2,680