펀스몬스터

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

· 19년 전 · 2413
<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,814
19년 전 조회 1,657
19년 전 조회 1,512
19년 전 조회 1,674
19년 전 조회 1,614
19년 전 조회 1,529
19년 전 조회 1,536
19년 전 조회 1,452
19년 전 조회 1,527
19년 전 조회 2,881
19년 전 조회 3,900
19년 전 조회 5,296
19년 전 조회 1,459
19년 전 조회 4,618
19년 전 조회 3,060
19년 전 조회 1,561
19년 전 조회 2,768
19년 전 조회 3,701
19년 전 조회 1,866
19년 전 조회 3,879
19년 전 조회 1,954
19년 전 조회 3,853
19년 전 조회 3,505
19년 전 조회 4,281
19년 전 조회 4,130
19년 전 조회 1,956
19년 전 조회 1,919
19년 전 조회 4,342
19년 전 조회 2,748
19년 전 조회 2,616
19년 전 조회 2,469
19년 전 조회 2,057
19년 전 조회 2,639
19년 전 조회 2,271
19년 전 조회 1,918
19년 전 조회 2,060
19년 전 조회 1,509
19년 전 조회 1,762
19년 전 조회 2,902
19년 전 조회 2,017
19년 전 조회 3,289
19년 전 조회 3,203
19년 전 조회 2,315
19년 전 조회 1,853
19년 전 조회 2,892
19년 전 조회 2,972
19년 전 조회 4,082
19년 전 조회 2,058
19년 전 조회 2,705
19년 전 조회 2,414
19년 전 조회 3,536
19년 전 조회 1,501
19년 전 조회 1,554
19년 전 조회 1,855
19년 전 조회 2,283
19년 전 조회 1,908
19년 전 조회 1,785
19년 전 조회 2,187
19년 전 조회 2,269
19년 전 조회 5,031
19년 전 조회 2,403
19년 전 조회 3,271
19년 전 조회 2,723
19년 전 조회 2,492
19년 전 조회 4,772
19년 전 조회 2,626
19년 전 조회 2,478
19년 전 조회 2,020
19년 전 조회 1,809
19년 전 조회 3,422
19년 전 조회 2,396
19년 전 조회 6,223
19년 전 조회 2,096
19년 전 조회 1,981
19년 전 조회 2,780
19년 전 조회 1,880
19년 전 조회 2,352
19년 전 조회 2,182
19년 전 조회 3,626
19년 전 조회 2,641
19년 전 조회 2,821
19년 전 조회 4,436
19년 전 조회 3,608
19년 전 조회 2,391
19년 전 조회 4,364
19년 전 조회 3,349
19년 전 조회 4,200
19년 전 조회 2,072
19년 전 조회 2,280
19년 전 조회 2,210
19년 전 조회 3,411
19년 전 조회 2,785
19년 전 조회 3,577
19년 전 조회 2,742
19년 전 조회 2,586
19년 전 조회 2,409
19년 전 조회 2,305
19년 전 조회 2,190
19년 전 조회 4,327
19년 전 조회 2,735