펀스몬스터

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

· 19년 전 · 2426
<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,825
19년 전 조회 1,671
19년 전 조회 1,524
19년 전 조회 1,686
19년 전 조회 1,629
19년 전 조회 1,547
19년 전 조회 1,549
19년 전 조회 1,473
19년 전 조회 1,541
19년 전 조회 2,899
19년 전 조회 3,922
19년 전 조회 5,313
19년 전 조회 1,471
19년 전 조회 4,635
19년 전 조회 3,071
19년 전 조회 1,579
19년 전 조회 2,783
19년 전 조회 3,715
19년 전 조회 1,882
19년 전 조회 3,890
19년 전 조회 1,972
19년 전 조회 3,865
19년 전 조회 3,515
19년 전 조회 4,296
19년 전 조회 4,142
19년 전 조회 1,966
19년 전 조회 1,934
19년 전 조회 4,351
19년 전 조회 2,760
19년 전 조회 2,631
19년 전 조회 2,485
19년 전 조회 2,071
19년 전 조회 2,652
19년 전 조회 2,286
19년 전 조회 1,936
19년 전 조회 2,072
19년 전 조회 1,522
19년 전 조회 1,777
19년 전 조회 2,922
19년 전 조회 2,030
19년 전 조회 3,298
19년 전 조회 3,218
19년 전 조회 2,327
19년 전 조회 1,868
19년 전 조회 2,912
19년 전 조회 2,984
19년 전 조회 4,099
19년 전 조회 2,068
19년 전 조회 2,716
19년 전 조회 2,427
19년 전 조회 3,553
19년 전 조회 1,511
19년 전 조회 1,570
19년 전 조회 1,864
19년 전 조회 2,299
19년 전 조회 1,917
19년 전 조회 1,801
19년 전 조회 2,196
19년 전 조회 2,285
19년 전 조회 5,043
19년 전 조회 2,417
19년 전 조회 3,284
19년 전 조회 2,741
19년 전 조회 2,505
19년 전 조회 4,785
19년 전 조회 2,646
19년 전 조회 2,490
19년 전 조회 2,032
19년 전 조회 1,818
19년 전 조회 3,433
19년 전 조회 2,412
19년 전 조회 6,238
19년 전 조회 2,103
19년 전 조회 1,997
19년 전 조회 2,799
19년 전 조회 1,890
19년 전 조회 2,366
19년 전 조회 2,194
19년 전 조회 3,639
19년 전 조회 2,650
19년 전 조회 2,837
19년 전 조회 4,451
19년 전 조회 3,621
19년 전 조회 2,402
19년 전 조회 4,381
19년 전 조회 3,360
19년 전 조회 4,218
19년 전 조회 2,091
19년 전 조회 2,295
19년 전 조회 2,221
19년 전 조회 3,424
19년 전 조회 2,802
19년 전 조회 3,597
19년 전 조회 2,762
19년 전 조회 2,598
19년 전 조회 2,423
19년 전 조회 2,310
19년 전 조회 2,198
19년 전 조회 4,339
19년 전 조회 2,754