펀스몬스터

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

· 19년 전 · 2349
<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,733
19년 전 조회 1,584
19년 전 조회 1,445
19년 전 조회 1,605
19년 전 조회 1,538
19년 전 조회 1,458
19년 전 조회 1,470
19년 전 조회 1,388
19년 전 조회 1,455
19년 전 조회 2,814
19년 전 조회 3,833
19년 전 조회 5,222
19년 전 조회 1,391
19년 전 조회 4,555
19년 전 조회 2,993
19년 전 조회 1,504
19년 전 조회 2,696
19년 전 조회 3,624
19년 전 조회 1,797
19년 전 조회 3,801
19년 전 조회 1,885
19년 전 조회 3,786
19년 전 조회 3,430
19년 전 조회 4,219
19년 전 조회 4,065
19년 전 조회 1,886
19년 전 조회 1,853
19년 전 조회 4,285
19년 전 조회 2,684
19년 전 조회 2,551
19년 전 조회 2,413
19년 전 조회 1,984
19년 전 조회 2,574
19년 전 조회 2,209
19년 전 조회 1,854
19년 전 조회 1,984
19년 전 조회 1,451
19년 전 조회 1,705
19년 전 조회 2,845
19년 전 조회 1,958
19년 전 조회 3,231
19년 전 조회 3,140
19년 전 조회 2,253
19년 전 조회 1,800
19년 전 조회 2,842
19년 전 조회 2,916
19년 전 조회 4,027
19년 전 조회 1,995
19년 전 조회 2,641
19년 전 조회 2,350
19년 전 조회 3,479
19년 전 조회 1,432
19년 전 조회 1,497
19년 전 조회 1,780
19년 전 조회 2,222
19년 전 조회 1,844
19년 전 조회 1,711
19년 전 조회 2,126
19년 전 조회 2,215
19년 전 조회 4,972
19년 전 조회 2,342
19년 전 조회 3,208
19년 전 조회 2,656
19년 전 조회 2,423
19년 전 조회 4,713
19년 전 조회 2,567
19년 전 조회 2,413
19년 전 조회 1,957
19년 전 조회 1,738
19년 전 조회 3,365
19년 전 조회 2,340
19년 전 조회 6,163
19년 전 조회 2,031
19년 전 조회 1,909
19년 전 조회 2,715
19년 전 조회 1,822
19년 전 조회 2,288
19년 전 조회 2,119
19년 전 조회 3,570
19년 전 조회 2,582
19년 전 조회 2,757
19년 전 조회 4,378
19년 전 조회 3,561
19년 전 조회 2,319
19년 전 조회 4,305
19년 전 조회 3,283
19년 전 조회 4,146
19년 전 조회 2,006
19년 전 조회 2,221
19년 전 조회 2,150
19년 전 조회 3,359
19년 전 조회 2,728
19년 전 조회 3,517
19년 전 조회 2,694
19년 전 조회 2,531
19년 전 조회 2,352
19년 전 조회 2,244
19년 전 조회 2,133
19년 전 조회 4,263
19년 전 조회 2,686