펀스몬스터

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

· 19년 전 · 2461
<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,865
19년 전 조회 1,710
19년 전 조회 1,562
19년 전 조회 1,733
19년 전 조회 1,665
19년 전 조회 1,583
19년 전 조회 1,591
19년 전 조회 1,513
19년 전 조회 1,580
19년 전 조회 2,942
19년 전 조회 3,960
19년 전 조회 5,354
19년 전 조회 1,512
19년 전 조회 4,679
19년 전 조회 3,108
19년 전 조회 1,629
19년 전 조회 2,816
19년 전 조회 3,754
19년 전 조회 1,920
19년 전 조회 3,930
19년 전 조회 2,007
19년 전 조회 3,902
19년 전 조회 3,550
19년 전 조회 4,336
19년 전 조회 4,180
19년 전 조회 2,006
19년 전 조회 1,972
19년 전 조회 4,395
19년 전 조회 2,795
19년 전 조회 2,678
19년 전 조회 2,524
19년 전 조회 2,107
19년 전 조회 2,694
19년 전 조회 2,322
19년 전 조회 1,979
19년 전 조회 2,112
19년 전 조회 1,561
19년 전 조회 1,812
19년 전 조회 2,956
19년 전 조회 2,070
19년 전 조회 3,336
19년 전 조회 3,252
19년 전 조회 2,365
19년 전 조회 1,911
19년 전 조회 2,953
19년 전 조회 3,022
19년 전 조회 4,140
19년 전 조회 2,113
19년 전 조회 2,758
19년 전 조회 2,462
19년 전 조회 3,593
19년 전 조회 1,541
19년 전 조회 1,608
19년 전 조회 1,897
19년 전 조회 2,345
19년 전 조회 1,958
19년 전 조회 1,839
19년 전 조회 2,234
19년 전 조회 2,321
19년 전 조회 5,086
19년 전 조회 2,466
19년 전 조회 3,322
19년 전 조회 2,780
19년 전 조회 2,544
19년 전 조회 4,830
19년 전 조회 2,688
19년 전 조회 2,529
19년 전 조회 2,079
19년 전 조회 1,864
19년 전 조회 3,475
19년 전 조회 2,454
19년 전 조회 6,289
19년 전 조회 2,153
19년 전 조회 2,034
19년 전 조회 2,834
19년 전 조회 1,931
19년 전 조회 2,402
19년 전 조회 2,233
19년 전 조회 3,683
19년 전 조회 2,686
19년 전 조회 2,871
19년 전 조회 4,494
19년 전 조회 3,667
19년 전 조회 2,436
19년 전 조회 4,424
19년 전 조회 3,402
19년 전 조회 4,264
19년 전 조회 2,133
19년 전 조회 2,333
19년 전 조회 2,262
19년 전 조회 3,471
19년 전 조회 2,845
19년 전 조회 3,629
19년 전 조회 2,809
19년 전 조회 2,634
19년 전 조회 2,465
19년 전 조회 2,361
19년 전 조회 2,248
19년 전 조회 4,386
19년 전 조회 2,796