펀스몬스터

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

· 19년 전 · 2348
<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,732
19년 전 조회 1,580
19년 전 조회 1,442
19년 전 조회 1,602
19년 전 조회 1,536
19년 전 조회 1,455
19년 전 조회 1,465
19년 전 조회 1,386
19년 전 조회 1,450
19년 전 조회 2,814
19년 전 조회 3,832
19년 전 조회 5,222
19년 전 조회 1,391
19년 전 조회 4,554
19년 전 조회 2,992
19년 전 조회 1,500
19년 전 조회 2,696
19년 전 조회 3,623
19년 전 조회 1,796
19년 전 조회 3,801
19년 전 조회 1,884
19년 전 조회 3,785
19년 전 조회 3,429
19년 전 조회 4,218
19년 전 조회 4,063
19년 전 조회 1,885
19년 전 조회 1,851
19년 전 조회 4,283
19년 전 조회 2,684
19년 전 조회 2,551
19년 전 조회 2,411
19년 전 조회 1,983
19년 전 조회 2,572
19년 전 조회 2,206
19년 전 조회 1,853
19년 전 조회 1,982
19년 전 조회 1,450
19년 전 조회 1,704
19년 전 조회 2,844
19년 전 조회 1,953
19년 전 조회 3,229
19년 전 조회 3,140
19년 전 조회 2,253
19년 전 조회 1,799
19년 전 조회 2,840
19년 전 조회 2,910
19년 전 조회 4,027
19년 전 조회 1,992
19년 전 조회 2,639
19년 전 조회 2,349
19년 전 조회 3,475
19년 전 조회 1,431
19년 전 조회 1,497
19년 전 조회 1,778
19년 전 조회 2,219
19년 전 조회 1,842
19년 전 조회 1,708
19년 전 조회 2,123
19년 전 조회 2,214
19년 전 조회 4,972
19년 전 조회 2,340
19년 전 조회 3,206
19년 전 조회 2,655
19년 전 조회 2,419
19년 전 조회 4,713
19년 전 조회 2,566
19년 전 조회 2,413
19년 전 조회 1,953
19년 전 조회 1,737
19년 전 조회 3,365
19년 전 조회 2,335
19년 전 조회 6,163
19년 전 조회 2,029
19년 전 조회 1,907
19년 전 조회 2,714
19년 전 조회 1,819
19년 전 조회 2,286
19년 전 조회 2,119
19년 전 조회 3,569
19년 전 조회 2,581
19년 전 조회 2,755
19년 전 조회 4,378
19년 전 조회 3,559
19년 전 조회 2,317
19년 전 조회 4,304
19년 전 조회 3,281
19년 전 조회 4,145
19년 전 조회 2,006
19년 전 조회 2,219
19년 전 조회 2,148
19년 전 조회 3,358
19년 전 조회 2,728
19년 전 조회 3,516
19년 전 조회 2,693
19년 전 조회 2,531
19년 전 조회 2,352
19년 전 조회 2,244
19년 전 조회 2,131
19년 전 조회 4,262
19년 전 조회 2,685