펀스몬스터

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

· 19년 전 · 2341
<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,725
19년 전 조회 1,572
19년 전 조회 1,437
19년 전 조회 1,594
19년 전 조회 1,529
19년 전 조회 1,448
19년 전 조회 1,454
19년 전 조회 1,378
19년 전 조회 1,445
19년 전 조회 2,808
19년 전 조회 3,827
19년 전 조회 5,213
19년 전 조회 1,383
19년 전 조회 4,546
19년 전 조회 2,987
19년 전 조회 1,491
19년 전 조회 2,691
19년 전 조회 3,616
19년 전 조회 1,785
19년 전 조회 3,790
19년 전 조회 1,877
19년 전 조회 3,778
19년 전 조회 3,421
19년 전 조회 4,207
19년 전 조회 4,051
19년 전 조회 1,881
19년 전 조회 1,845
19년 전 조회 4,275
19년 전 조회 2,680
19년 전 조회 2,547
19년 전 조회 2,403
19년 전 조회 1,976
19년 전 조회 2,567
19년 전 조회 2,199
19년 전 조회 1,846
19년 전 조회 1,971
19년 전 조회 1,440
19년 전 조회 1,698
19년 전 조회 2,836
19년 전 조회 1,949
19년 전 조회 3,220
19년 전 조회 3,132
19년 전 조회 2,244
19년 전 조회 1,791
19년 전 조회 2,835
19년 전 조회 2,904
19년 전 조회 4,017
19년 전 조회 1,984
19년 전 조회 2,631
19년 전 조회 2,342
19년 전 조회 3,468
19년 전 조회 1,423
19년 전 조회 1,490
19년 전 조회 1,770
19년 전 조회 2,211
19년 전 조회 1,839
19년 전 조회 1,704
19년 전 조회 2,115
19년 전 조회 2,204
19년 전 조회 4,962
19년 전 조회 2,333
19년 전 조회 3,201
19년 전 조회 2,648
19년 전 조회 2,412
19년 전 조회 4,706
19년 전 조회 2,560
19년 전 조회 2,406
19년 전 조회 1,948
19년 전 조회 1,734
19년 전 조회 3,355
19년 전 조회 2,327
19년 전 조회 6,157
19년 전 조회 2,021
19년 전 조회 1,901
19년 전 조회 2,704
19년 전 조회 1,810
19년 전 조회 2,280
19년 전 조회 2,111
19년 전 조회 3,561
19년 전 조회 2,573
19년 전 조회 2,751
19년 전 조회 4,371
19년 전 조회 3,552
19년 전 조회 2,309
19년 전 조회 4,299
19년 전 조회 3,270
19년 전 조회 4,138
19년 전 조회 1,999
19년 전 조회 2,213
19년 전 조회 2,142
19년 전 조회 3,349
19년 전 조회 2,719
19년 전 조회 3,508
19년 전 조회 2,685
19년 전 조회 2,522
19년 전 조회 2,343
19년 전 조회 2,233
19년 전 조회 2,125
19년 전 조회 4,252
19년 전 조회 2,676
🐛 버그신고