펀스몬스터

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

· 19년 전 · 2504
<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,901
19년 전 조회 1,752
19년 전 조회 1,603
19년 전 조회 1,773
19년 전 조회 1,709
19년 전 조회 1,633
19년 전 조회 1,639
19년 전 조회 1,560
19년 전 조회 1,620
19년 전 조회 2,981
19년 전 조회 3,999
19년 전 조회 5,398
19년 전 조회 1,560
19년 전 조회 4,718
19년 전 조회 3,150
19년 전 조회 1,668
19년 전 조회 2,858
19년 전 조회 3,795
19년 전 조회 1,960
19년 전 조회 3,978
19년 전 조회 2,046
19년 전 조회 3,947
19년 전 조회 3,585
19년 전 조회 4,374
19년 전 조회 4,223
19년 전 조회 2,047
19년 전 조회 2,014
19년 전 조회 4,442
19년 전 조회 2,845
19년 전 조회 2,713
19년 전 조회 2,566
19년 전 조회 2,152
19년 전 조회 2,734
19년 전 조회 2,362
19년 전 조회 2,019
19년 전 조회 2,156
19년 전 조회 1,602
19년 전 조회 1,856
19년 전 조회 3,003
19년 전 조회 2,119
19년 전 조회 3,374
19년 전 조회 3,289
19년 전 조회 2,403
19년 전 조회 1,959
19년 전 조회 2,994
19년 전 조회 3,053
19년 전 조회 4,182
19년 전 조회 2,155
19년 전 조회 2,800
19년 전 조회 2,505
19년 전 조회 3,638
19년 전 조회 1,585
19년 전 조회 1,643
19년 전 조회 1,936
19년 전 조회 2,381
19년 전 조회 1,995
19년 전 조회 1,877
19년 전 조회 2,270
19년 전 조회 2,363
19년 전 조회 5,127
19년 전 조회 2,506
19년 전 조회 3,367
19년 전 조회 2,826
19년 전 조회 2,578
19년 전 조회 4,863
19년 전 조회 2,721
19년 전 조회 2,574
19년 전 조회 2,116
19년 전 조회 1,908
19년 전 조회 3,515
19년 전 조회 2,490
19년 전 조회 6,330
19년 전 조회 2,193
19년 전 조회 2,075
19년 전 조회 2,875
19년 전 조회 1,969
19년 전 조회 2,441
19년 전 조회 2,270
19년 전 조회 3,726
19년 전 조회 2,726
19년 전 조회 2,915
19년 전 조회 4,532
19년 전 조회 3,705
19년 전 조회 2,476
19년 전 조회 4,465
19년 전 조회 3,444
19년 전 조회 4,303
19년 전 조회 2,176
19년 전 조회 2,372
19년 전 조회 2,305
19년 전 조회 3,510
19년 전 조회 2,876
19년 전 조회 3,674
19년 전 조회 2,841
19년 전 조회 2,669
19년 전 조회 2,507
19년 전 조회 2,395
19년 전 조회 2,291
19년 전 조회 4,426
19년 전 조회 2,841