펀스몬스터

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

· 19년 전 · 2337
<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,719
19년 전 조회 1,566
19년 전 조회 1,432
19년 전 조회 1,589
19년 전 조회 1,523
19년 전 조회 1,443
19년 전 조회 1,450
19년 전 조회 1,373
19년 전 조회 1,440
19년 전 조회 2,803
19년 전 조회 3,824
19년 전 조회 5,209
19년 전 조회 1,375
19년 전 조회 4,542
19년 전 조회 2,983
19년 전 조회 1,491
19년 전 조회 2,687
19년 전 조회 3,614
19년 전 조회 1,781
19년 전 조회 3,785
19년 전 조회 1,873
19년 전 조회 3,773
19년 전 조회 3,420
19년 전 조회 4,200
19년 전 조회 4,048
19년 전 조회 1,875
19년 전 조회 1,844
19년 전 조회 4,272
19년 전 조회 2,674
19년 전 조회 2,542
19년 전 조회 2,400
19년 전 조회 1,974
19년 전 조회 2,562
19년 전 조회 2,194
19년 전 조회 1,844
19년 전 조회 1,965
19년 전 조회 1,438
19년 전 조회 1,693
19년 전 조회 2,833
19년 전 조회 1,946
19년 전 조회 3,217
19년 전 조회 3,129
19년 전 조회 2,239
19년 전 조회 1,786
19년 전 조회 2,831
19년 전 조회 2,901
19년 전 조회 4,013
19년 전 조회 1,976
19년 전 조회 2,626
19년 전 조회 2,338
19년 전 조회 3,463
19년 전 조회 1,420
19년 전 조회 1,487
19년 전 조회 1,767
19년 전 조회 2,208
19년 전 조회 1,836
19년 전 조회 1,697
19년 전 조회 2,108
19년 전 조회 2,203
19년 전 조회 4,959
19년 전 조회 2,329
19년 전 조회 3,196
19년 전 조회 2,645
19년 전 조회 2,409
19년 전 조회 4,702
19년 전 조회 2,557
19년 전 조회 2,405
19년 전 조회 1,944
19년 전 조회 1,726
19년 전 조회 3,350
19년 전 조회 2,325
19년 전 조회 6,155
19년 전 조회 2,017
19년 전 조회 1,900
19년 전 조회 2,702
19년 전 조회 1,804
19년 전 조회 2,276
19년 전 조회 2,106
19년 전 조회 3,558
19년 전 조회 2,572
19년 전 조회 2,744
19년 전 조회 4,366
19년 전 조회 3,547
19년 전 조회 2,307
19년 전 조회 4,296
19년 전 조회 3,266
19년 전 조회 4,132
19년 전 조회 1,995
19년 전 조회 2,209
19년 전 조회 2,140
19년 전 조회 3,344
19년 전 조회 2,715
19년 전 조회 3,505
19년 전 조회 2,679
19년 전 조회 2,518
19년 전 조회 2,340
19년 전 조회 2,232
19년 전 조회 2,124
19년 전 조회 4,250
19년 전 조회 2,673
🐛 버그신고