펀스몬스터

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

· 19년 전 · 2495
<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,894
19년 전 조회 1,747
19년 전 조회 1,595
19년 전 조회 1,766
19년 전 조회 1,700
19년 전 조회 1,625
19년 전 조회 1,628
19년 전 조회 1,550
19년 전 조회 1,608
19년 전 조회 2,972
19년 전 조회 3,989
19년 전 조회 5,386
19년 전 조회 1,549
19년 전 조회 4,708
19년 전 조회 3,140
19년 전 조회 1,659
19년 전 조회 2,851
19년 전 조회 3,789
19년 전 조회 1,948
19년 전 조회 3,963
19년 전 조회 2,035
19년 전 조회 3,932
19년 전 조회 3,578
19년 전 조회 4,361
19년 전 조회 4,219
19년 전 조회 2,039
19년 전 조회 2,004
19년 전 조회 4,431
19년 전 조회 2,828
19년 전 조회 2,707
19년 전 조회 2,555
19년 전 조회 2,140
19년 전 조회 2,729
19년 전 조회 2,353
19년 전 조회 2,006
19년 전 조회 2,149
19년 전 조회 1,594
19년 전 조회 1,845
19년 전 조회 2,993
19년 전 조회 2,109
19년 전 조회 3,367
19년 전 조회 3,282
19년 전 조회 2,393
19년 전 조회 1,946
19년 전 조회 2,981
19년 전 조회 3,043
19년 전 조회 4,174
19년 전 조회 2,143
19년 전 조회 2,791
19년 전 조회 2,496
19년 전 조회 3,629
19년 전 조회 1,578
19년 전 조회 1,633
19년 전 조회 1,926
19년 전 조회 2,373
19년 전 조회 1,988
19년 전 조회 1,865
19년 전 조회 2,263
19년 전 조회 2,352
19년 전 조회 5,115
19년 전 조회 2,499
19년 전 조회 3,356
19년 전 조회 2,814
19년 전 조회 2,570
19년 전 조회 4,853
19년 전 조회 2,714
19년 전 조회 2,564
19년 전 조회 2,112
19년 전 조회 1,899
19년 전 조회 3,503
19년 전 조회 2,476
19년 전 조회 6,316
19년 전 조회 2,183
19년 전 조회 2,066
19년 전 조회 2,862
19년 전 조회 1,962
19년 전 조회 2,432
19년 전 조회 2,265
19년 전 조회 3,716
19년 전 조회 2,719
19년 전 조회 2,910
19년 전 조회 4,522
19년 전 조회 3,696
19년 전 조회 2,469
19년 전 조회 4,459
19년 전 조회 3,434
19년 전 조회 4,295
19년 전 조회 2,168
19년 전 조회 2,366
19년 전 조회 2,300
19년 전 조회 3,503
19년 전 조회 2,870
19년 전 조회 3,664
19년 전 조회 2,832
19년 전 조회 2,666
19년 전 조회 2,500
19년 전 조회 2,391
19년 전 조회 2,280
19년 전 조회 4,412
19년 전 조회 2,833