펀스몬스터

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

· 19년 전 · 2332
<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,716
19년 전 조회 1,562
19년 전 조회 1,427
19년 전 조회 1,586
19년 전 조회 1,520
19년 전 조회 1,440
19년 전 조회 1,444
19년 전 조회 1,367
19년 전 조회 1,437
19년 전 조회 2,801
19년 전 조회 3,819
19년 전 조회 5,206
19년 전 조회 1,370
19년 전 조회 4,537
19년 전 조회 2,977
19년 전 조회 1,487
19년 전 조회 2,683
19년 전 조회 3,610
19년 전 조회 1,777
19년 전 조회 3,782
19년 전 조회 1,870
19년 전 조회 3,769
19년 전 조회 3,415
19년 전 조회 4,198
19년 전 조회 4,043
19년 전 조회 1,871
19년 전 조회 1,838
19년 전 조회 4,269
19년 전 조회 2,671
19년 전 조회 2,539
19년 전 조회 2,396
19년 전 조회 1,970
19년 전 조회 2,559
19년 전 조회 2,191
19년 전 조회 1,840
19년 전 조회 1,960
19년 전 조회 1,433
19년 전 조회 1,686
19년 전 조회 2,830
19년 전 조회 1,942
19년 전 조회 3,214
19년 전 조회 3,124
19년 전 조회 2,234
19년 전 조회 1,781
19년 전 조회 2,827
19년 전 조회 2,894
19년 전 조회 4,007
19년 전 조회 1,970
19년 전 조회 2,621
19년 전 조회 2,333
19년 전 조회 3,460
19년 전 조회 1,417
19년 전 조회 1,481
19년 전 조회 1,763
19년 전 조회 2,205
19년 전 조회 1,832
19년 전 조회 1,693
19년 전 조회 2,104
19년 전 조회 2,200
19년 전 조회 4,956
19년 전 조회 2,325
19년 전 조회 3,192
19년 전 조회 2,640
19년 전 조회 2,405
19년 전 조회 4,697
19년 전 조회 2,552
19년 전 조회 2,402
19년 전 조회 1,940
19년 전 조회 1,721
19년 전 조회 3,347
19년 전 조회 2,320
19년 전 조회 6,151
19년 전 조회 2,012
19년 전 조회 1,895
19년 전 조회 2,698
19년 전 조회 1,798
19년 전 조회 2,272
19년 전 조회 2,103
19년 전 조회 3,554
19년 전 조회 2,571
19년 전 조회 2,741
19년 전 조회 4,363
19년 전 조회 3,543
19년 전 조회 2,305
19년 전 조회 4,290
19년 전 조회 3,264
19년 전 조회 4,130
19년 전 조회 1,993
19년 전 조회 2,207
19년 전 조회 2,135
19년 전 조회 3,340
19년 전 조회 2,712
19년 전 조회 3,502
19년 전 조회 2,675
19년 전 조회 2,514
19년 전 조회 2,337
19년 전 조회 2,229
19년 전 조회 2,118
19년 전 조회 4,247
19년 전 조회 2,667
🐛 버그신고