펀스몬스터

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

· 19년 전 · 2334
<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,717
19년 전 조회 1,563
19년 전 조회 1,428
19년 전 조회 1,587
19년 전 조회 1,522
19년 전 조회 1,440
19년 전 조회 1,445
19년 전 조회 1,368
19년 전 조회 1,437
19년 전 조회 2,802
19년 전 조회 3,820
19년 전 조회 5,207
19년 전 조회 1,370
19년 전 조회 4,538
19년 전 조회 2,977
19년 전 조회 1,489
19년 전 조회 2,684
19년 전 조회 3,612
19년 전 조회 1,778
19년 전 조회 3,782
19년 전 조회 1,872
19년 전 조회 3,770
19년 전 조회 3,417
19년 전 조회 4,200
19년 전 조회 4,044
19년 전 조회 1,872
19년 전 조회 1,839
19년 전 조회 4,271
19년 전 조회 2,674
19년 전 조회 2,540
19년 전 조회 2,397
19년 전 조회 1,971
19년 전 조회 2,560
19년 전 조회 2,192
19년 전 조회 1,841
19년 전 조회 1,964
19년 전 조회 1,434
19년 전 조회 1,689
19년 전 조회 2,830
19년 전 조회 1,944
19년 전 조회 3,215
19년 전 조회 3,126
19년 전 조회 2,238
19년 전 조회 1,785
19년 전 조회 2,830
19년 전 조회 2,895
19년 전 조회 4,007
19년 전 조회 1,972
19년 전 조회 2,621
19년 전 조회 2,335
19년 전 조회 3,462
19년 전 조회 1,418
19년 전 조회 1,484
19년 전 조회 1,765
19년 전 조회 2,205
19년 전 조회 1,832
19년 전 조회 1,696
19년 전 조회 2,106
19년 전 조회 2,201
19년 전 조회 4,958
19년 전 조회 2,326
19년 전 조회 3,194
19년 전 조회 2,643
19년 전 조회 2,407
19년 전 조회 4,698
19년 전 조회 2,554
19년 전 조회 2,403
19년 전 조회 1,941
19년 전 조회 1,724
19년 전 조회 3,348
19년 전 조회 2,321
19년 전 조회 6,151
19년 전 조회 2,013
19년 전 조회 1,896
19년 전 조회 2,698
19년 전 조회 1,801
19년 전 조회 2,274
19년 전 조회 2,104
19년 전 조회 3,554
19년 전 조회 2,572
19년 전 조회 2,741
19년 전 조회 4,363
19년 전 조회 3,544
19년 전 조회 2,306
19년 전 조회 4,292
19년 전 조회 3,264
19년 전 조회 4,130
19년 전 조회 1,993
19년 전 조회 2,208
19년 전 조회 2,135
19년 전 조회 3,343
19년 전 조회 2,714
19년 전 조회 3,503
19년 전 조회 2,676
19년 전 조회 2,515
19년 전 조회 2,338
19년 전 조회 2,230
19년 전 조회 2,120
19년 전 조회 4,248
19년 전 조회 2,668
🐛 버그신고