펀스몬스터

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

· 19년 전 · 2459
<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,860
19년 전 조회 1,708
19년 전 조회 1,561
19년 전 조회 1,731
19년 전 조회 1,663
19년 전 조회 1,581
19년 전 조회 1,590
19년 전 조회 1,511
19년 전 조회 1,578
19년 전 조회 2,939
19년 전 조회 3,958
19년 전 조회 5,353
19년 전 조회 1,511
19년 전 조회 4,679
19년 전 조회 3,108
19년 전 조회 1,623
19년 전 조회 2,814
19년 전 조회 3,753
19년 전 조회 1,918
19년 전 조회 3,927
19년 전 조회 2,007
19년 전 조회 3,901
19년 전 조회 3,547
19년 전 조회 4,334
19년 전 조회 4,178
19년 전 조회 2,003
19년 전 조회 1,971
19년 전 조회 4,393
19년 전 조회 2,795
19년 전 조회 2,678
19년 전 조회 2,521
19년 전 조회 2,105
19년 전 조회 2,692
19년 전 조회 2,320
19년 전 조회 1,976
19년 전 조회 2,111
19년 전 조회 1,560
19년 전 조회 1,811
19년 전 조회 2,955
19년 전 조회 2,067
19년 전 조회 3,335
19년 전 조회 3,251
19년 전 조회 2,362
19년 전 조회 1,910
19년 전 조회 2,950
19년 전 조회 3,019
19년 전 조회 4,137
19년 전 조회 2,111
19년 전 조회 2,757
19년 전 조회 2,460
19년 전 조회 3,591
19년 전 조회 1,539
19년 전 조회 1,606
19년 전 조회 1,893
19년 전 조회 2,341
19년 전 조회 1,955
19년 전 조회 1,834
19년 전 조회 2,232
19년 전 조회 2,320
19년 전 조회 5,084
19년 전 조회 2,460
19년 전 조회 3,322
19년 전 조회 2,779
19년 전 조회 2,543
19년 전 조회 4,828
19년 전 조회 2,685
19년 전 조회 2,526
19년 전 조회 2,076
19년 전 조회 1,863
19년 전 조회 3,472
19년 전 조회 2,452
19년 전 조회 6,286
19년 전 조회 2,147
19년 전 조회 2,031
19년 전 조회 2,833
19년 전 조회 1,930
19년 전 조회 2,401
19년 전 조회 2,230
19년 전 조회 3,680
19년 전 조회 2,683
19년 전 조회 2,871
19년 전 조회 4,490
19년 전 조회 3,666
19년 전 조회 2,433
19년 전 조회 4,421
19년 전 조회 3,402
19년 전 조회 4,262
19년 전 조회 2,132
19년 전 조회 2,331
19년 전 조회 2,260
19년 전 조회 3,468
19년 전 조회 2,840
19년 전 조회 3,627
19년 전 조회 2,806
19년 전 조회 2,633
19년 전 조회 2,462
19년 전 조회 2,357
19년 전 조회 2,246
19년 전 조회 4,384
19년 전 조회 2,794