펀스몬스터

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

· 19년 전 · 2339
<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,724
19년 전 조회 1,569
19년 전 조회 1,436
19년 전 조회 1,594
19년 전 조회 1,527
19년 전 조회 1,448
19년 전 조회 1,454
19년 전 조회 1,377
19년 전 조회 1,445
19년 전 조회 2,808
19년 전 조회 3,827
19년 전 조회 5,213
19년 전 조회 1,381
19년 전 조회 4,545
19년 전 조회 2,987
19년 전 조회 1,491
19년 전 조회 2,691
19년 전 조회 3,616
19년 전 조회 1,784
19년 전 조회 3,789
19년 전 조회 1,875
19년 전 조회 3,775
19년 전 조회 3,420
19년 전 조회 4,205
19년 전 조회 4,051
19년 전 조회 1,879
19년 전 조회 1,845
19년 전 조회 4,275
19년 전 조회 2,679
19년 전 조회 2,545
19년 전 조회 2,403
19년 전 조회 1,975
19년 전 조회 2,564
19년 전 조회 2,197
19년 전 조회 1,846
19년 전 조회 1,969
19년 전 조회 1,439
19년 전 조회 1,696
19년 전 조회 2,836
19년 전 조회 1,947
19년 전 조회 3,220
19년 전 조회 3,132
19년 전 조회 2,243
19년 전 조회 1,789
19년 전 조회 2,835
19년 전 조회 2,903
19년 전 조회 4,015
19년 전 조회 1,982
19년 전 조회 2,629
19년 전 조회 2,340
19년 전 조회 3,466
19년 전 조회 1,423
19년 전 조회 1,488
19년 전 조회 1,769
19년 전 조회 2,210
19년 전 조회 1,838
19년 전 조회 1,703
19년 전 조회 2,115
19년 전 조회 2,203
19년 전 조회 4,961
19년 전 조회 2,332
19년 전 조회 3,200
19년 전 조회 2,648
19년 전 조회 2,412
19년 전 조회 4,705
19년 전 조회 2,560
19년 전 조회 2,406
19년 전 조회 1,947
19년 전 조회 1,731
19년 전 조회 3,355
19년 전 조회 2,327
19년 전 조회 6,157
19년 전 조회 2,020
19년 전 조회 1,901
19년 전 조회 2,702
19년 전 조회 1,808
19년 전 조회 2,278
19년 전 조회 2,110
19년 전 조회 3,560
19년 전 조회 2,573
19년 전 조회 2,750
19년 전 조회 4,371
19년 전 조회 3,552
19년 전 조회 2,309
19년 전 조회 4,298
19년 전 조회 3,269
19년 전 조회 4,137
19년 전 조회 1,998
19년 전 조회 2,213
19년 전 조회 2,141
19년 전 조회 3,349
19년 전 조회 2,718
19년 전 조회 3,507
19년 전 조회 2,684
19년 전 조회 2,522
19년 전 조회 2,342
19년 전 조회 2,233
19년 전 조회 2,125
19년 전 조회 4,252
19년 전 조회 2,676
🐛 버그신고