펀스몬스터

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

· 19년 전 · 2372
<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,744
19년 전 조회 1,602
19년 전 조회 1,456
19년 전 조회 1,618
19년 전 조회 1,564
19년 전 조회 1,476
19년 전 조회 1,483
19년 전 조회 1,400
19년 전 조회 1,481
19년 전 조회 2,827
19년 전 조회 3,842
19년 전 조회 5,235
19년 전 조회 1,404
19년 전 조회 4,565
19년 전 조회 3,006
19년 전 조회 1,518
19년 전 조회 2,712
19년 전 조회 3,653
19년 전 조회 1,814
19년 전 조회 3,820
19년 전 조회 1,907
19년 전 조회 3,795
19년 전 조회 3,444
19년 전 조회 4,229
19년 전 조회 4,077
19년 전 조회 1,900
19년 전 조회 1,876
19년 전 조회 4,294
19년 전 조회 2,696
19년 전 조회 2,567
19년 전 조회 2,431
19년 전 조회 2,002
19년 전 조회 2,583
19년 전 조회 2,219
19년 전 조회 1,875
19년 전 조회 2,002
19년 전 조회 1,466
19년 전 조회 1,717
19년 전 조회 2,857
19년 전 조회 1,978
19년 전 조회 3,246
19년 전 조회 3,153
19년 전 조회 2,264
19년 전 조회 1,812
19년 전 조회 2,853
19년 전 조회 2,925
19년 전 조회 4,040
19년 전 조회 2,010
19년 전 조회 2,653
19년 전 조회 2,373
19년 전 조회 3,495
19년 전 조회 1,446
19년 전 조회 1,508
19년 전 조회 1,800
19년 전 조회 2,240
19년 전 조회 1,860
19년 전 조회 1,726
19년 전 조회 2,134
19년 전 조회 2,228
19년 전 조회 4,980
19년 전 조회 2,350
19년 전 조회 3,234
19년 전 조회 2,667
19년 전 조회 2,445
19년 전 조회 4,728
19년 전 조회 2,584
19년 전 조회 2,427
19년 전 조회 1,971
19년 전 조회 1,753
19년 전 조회 3,379
19년 전 조회 2,349
19년 전 조회 6,172
19년 전 조회 2,039
19년 전 조회 1,921
19년 전 조회 2,723
19년 전 조회 1,829
19년 전 조회 2,299
19년 전 조회 2,131
19년 전 조회 3,577
19년 전 조회 2,599
19년 전 조회 2,769
19년 전 조회 4,386
19년 전 조회 3,565
19년 전 조회 2,340
19년 전 조회 4,315
19년 전 조회 3,306
19년 전 조회 4,156
19년 전 조회 2,026
19년 전 조회 2,238
19년 전 조회 2,168
19년 전 조회 3,366
19년 전 조회 2,738
19년 전 조회 3,540
19년 전 조회 2,702
19년 전 조회 2,537
19년 전 조회 2,363
19년 전 조회 2,248
19년 전 조회 2,140
19년 전 조회 4,280
19년 전 조회 2,696