펀스몬스터

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

· 19년 전 · 2335
<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,719
19년 전 조회 1,566
19년 전 조회 1,432
19년 전 조회 1,589
19년 전 조회 1,523
19년 전 조회 1,442
19년 전 조회 1,450
19년 전 조회 1,372
19년 전 조회 1,440
19년 전 조회 2,803
19년 전 조회 3,822
19년 전 조회 5,209
19년 전 조회 1,374
19년 전 조회 4,541
19년 전 조회 2,982
19년 전 조회 1,491
19년 전 조회 2,686
19년 전 조회 3,614
19년 전 조회 1,780
19년 전 조회 3,784
19년 전 조회 1,873
19년 전 조회 3,772
19년 전 조회 3,418
19년 전 조회 4,200
19년 전 조회 4,048
19년 전 조회 1,875
19년 전 조회 1,842
19년 전 조회 4,271
19년 전 조회 2,674
19년 전 조회 2,541
19년 전 조회 2,399
19년 전 조회 1,973
19년 전 조회 2,562
19년 전 조회 2,194
19년 전 조회 1,841
19년 전 조회 1,965
19년 전 조회 1,437
19년 전 조회 1,691
19년 전 조회 2,833
19년 전 조회 1,944
19년 전 조회 3,215
19년 전 조회 3,128
19년 전 조회 2,238
19년 전 조회 1,786
19년 전 조회 2,830
19년 전 조회 2,899
19년 전 조회 4,012
19년 전 조회 1,976
19년 전 조회 2,624
19년 전 조회 2,336
19년 전 조회 3,462
19년 전 조회 1,420
19년 전 조회 1,487
19년 전 조회 1,767
19년 전 조회 2,207
19년 전 조회 1,835
19년 전 조회 1,697
19년 전 조회 2,108
19년 전 조회 2,203
19년 전 조회 4,959
19년 전 조회 2,329
19년 전 조회 3,195
19년 전 조회 2,644
19년 전 조회 2,407
19년 전 조회 4,700
19년 전 조회 2,555
19년 전 조회 2,405
19년 전 조회 1,942
19년 전 조회 1,726
19년 전 조회 3,350
19년 전 조회 2,324
19년 전 조회 6,154
19년 전 조회 2,016
19년 전 조회 1,898
19년 전 조회 2,702
19년 전 조회 1,803
19년 전 조회 2,275
19년 전 조회 2,106
19년 전 조회 3,556
19년 전 조회 2,572
19년 전 조회 2,744
19년 전 조회 4,366
19년 전 조회 3,546
19년 전 조회 2,306
19년 전 조회 4,294
19년 전 조회 3,266
19년 전 조회 4,132
19년 전 조회 1,993
19년 전 조회 2,209
19년 전 조회 2,137
19년 전 조회 3,344
19년 전 조회 2,715
19년 전 조회 3,505
19년 전 조회 2,678
19년 전 조회 2,518
19년 전 조회 2,339
19년 전 조회 2,232
19년 전 조회 2,123
19년 전 조회 4,249
19년 전 조회 2,671
🐛 버그신고