펀스몬스터

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

· 19년 전 · 2451
<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,853
19년 전 조회 1,698
19년 전 조회 1,557
19년 전 조회 1,719
19년 전 조회 1,656
19년 전 조회 1,570
19년 전 조회 1,583
19년 전 조회 1,500
19년 전 조회 1,571
19년 전 조회 2,930
19년 전 조회 3,951
19년 전 조회 5,338
19년 전 조회 1,498
19년 전 조회 4,656
19년 전 조회 3,101
19년 전 조회 1,611
19년 전 조회 2,804
19년 전 조회 3,746
19년 전 조회 1,910
19년 전 조회 3,915
19년 전 조회 1,997
19년 전 조회 3,891
19년 전 조회 3,542
19년 전 조회 4,328
19년 전 조회 4,171
19년 전 조회 1,994
19년 전 조회 1,962
19년 전 조회 4,387
19년 전 조회 2,783
19년 전 조회 2,667
19년 전 조회 2,513
19년 전 조회 2,098
19년 전 조회 2,685
19년 전 조회 2,310
19년 전 조회 1,969
19년 전 조회 2,096
19년 전 조회 1,552
19년 전 조회 1,806
19년 전 조회 2,947
19년 전 조회 2,057
19년 전 조회 3,325
19년 전 조회 3,240
19년 전 조회 2,354
19년 전 조회 1,899
19년 전 조회 2,937
19년 전 조회 3,004
19년 전 조회 4,125
19년 전 조회 2,100
19년 전 조회 2,746
19년 전 조회 2,452
19년 전 조회 3,573
19년 전 조회 1,536
19년 전 조회 1,594
19년 전 조회 1,883
19년 전 조회 2,331
19년 전 조회 1,944
19년 전 조회 1,826
19년 전 조회 2,223
19년 전 조회 2,311
19년 전 조회 5,075
19년 전 조회 2,447
19년 전 조회 3,315
19년 전 조회 2,770
19년 전 조회 2,536
19년 전 조회 4,818
19년 전 조회 2,676
19년 전 조회 2,520
19년 전 조회 2,061
19년 전 조회 1,849
19년 전 조회 3,463
19년 전 조회 2,445
19년 전 조회 6,270
19년 전 조회 2,134
19년 전 조회 2,021
19년 전 조회 2,824
19년 전 조회 1,915
19년 전 조회 2,390
19년 전 조회 2,219
19년 전 조회 3,672
19년 전 조회 2,679
19년 전 조회 2,865
19년 전 조회 4,483
19년 전 조회 3,656
19년 전 조회 2,429
19년 전 조회 4,411
19년 전 조회 3,392
19년 전 조회 4,251
19년 전 조회 2,122
19년 전 조회 2,320
19년 전 조회 2,249
19년 전 조회 3,457
19년 전 조회 2,834
19년 전 조회 3,622
19년 전 조회 2,796
19년 전 조회 2,623
19년 전 조회 2,449
19년 전 조회 2,345
19년 전 조회 2,237
19년 전 조회 4,375
19년 전 조회 2,780