펀스몬스터

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

· 19년 전 · 2389
<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,769
19년 전 조회 1,628
19년 전 조회 1,483
19년 전 조회 1,638
19년 전 조회 1,585
19년 전 조회 1,493
19년 전 조회 1,505
19년 전 조회 1,424
19년 전 조회 1,500
19년 전 조회 2,854
19년 전 조회 3,871
19년 전 조회 5,264
19년 전 조회 1,420
19년 전 조회 4,587
19년 전 조회 3,026
19년 전 조회 1,541
19년 전 조회 2,739
19년 전 조회 3,675
19년 전 조회 1,837
19년 전 조회 3,842
19년 전 조회 1,930
19년 전 조회 3,821
19년 전 조회 3,470
19년 전 조회 4,248
19년 전 조회 4,095
19년 전 조회 1,928
19년 전 조회 1,895
19년 전 조회 4,311
19년 전 조회 2,717
19년 전 조회 2,590
19년 전 조회 2,449
19년 전 조회 2,023
19년 전 조회 2,613
19년 전 조회 2,241
19년 전 조회 1,898
19년 전 조회 2,027
19년 전 조회 1,491
19년 전 조회 1,738
19년 전 조회 2,879
19년 전 조회 1,996
19년 전 조회 3,268
19년 전 조회 3,175
19년 전 조회 2,280
19년 전 조회 1,824
19년 전 조회 2,868
19년 전 조회 2,941
19년 전 조회 4,061
19년 전 조회 2,026
19년 전 조회 2,674
19년 전 조회 2,390
19년 전 조회 3,513
19년 전 조회 1,467
19년 전 조회 1,524
19년 전 조회 1,820
19년 전 조회 2,261
19년 전 조회 1,882
19년 전 조회 1,749
19년 전 조회 2,159
19년 전 조회 2,248
19년 전 조회 5,006
19년 전 조회 2,375
19년 전 조회 3,250
19년 전 조회 2,691
19년 전 조회 2,467
19년 전 조회 4,742
19년 전 조회 2,605
19년 전 조회 2,449
19년 전 조회 1,992
19년 전 조회 1,778
19년 전 조회 3,395
19년 전 조회 2,370
19년 전 조회 6,198
19년 전 조회 2,065
19년 전 조회 1,949
19년 전 조회 2,746
19년 전 조회 1,856
19년 전 조회 2,323
19년 전 조회 2,151
19년 전 조회 3,602
19년 전 조회 2,620
19년 전 조회 2,787
19년 전 조회 4,406
19년 전 조회 3,583
19년 전 조회 2,368
19년 전 조회 4,337
19년 전 조회 3,324
19년 전 조회 4,177
19년 전 조회 2,047
19년 전 조회 2,254
19년 전 조회 2,185
19년 전 조회 3,383
19년 전 조회 2,760
19년 전 조회 3,558
19년 전 조회 2,712
19년 전 조회 2,559
19년 전 조회 2,386
19년 전 조회 2,270
19년 전 조회 2,164
19년 전 조회 4,300
19년 전 조회 2,719