펀스몬스터

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

· 19년 전 · 2328
<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,713
19년 전 조회 1,558
19년 전 조회 1,424
19년 전 조회 1,582
19년 전 조회 1,517
19년 전 조회 1,436
19년 전 조회 1,442
19년 전 조회 1,365
19년 전 조회 1,433
19년 전 조회 2,797
19년 전 조회 3,814
19년 전 조회 5,202
19년 전 조회 1,367
19년 전 조회 4,533
19년 전 조회 2,976
19년 전 조회 1,485
19년 전 조회 2,679
19년 전 조회 3,606
19년 전 조회 1,773
19년 전 조회 3,779
19년 전 조회 1,866
19년 전 조회 3,765
19년 전 조회 3,414
19년 전 조회 4,194
19년 전 조회 4,040
19년 전 조회 1,869
19년 전 조회 1,835
19년 전 조회 4,265
19년 전 조회 2,668
19년 전 조회 2,536
19년 전 조회 2,391
19년 전 조회 1,966
19년 전 조회 2,555
19년 전 조회 2,187
19년 전 조회 1,837
19년 전 조회 1,957
19년 전 조회 1,430
19년 전 조회 1,684
19년 전 조회 2,825
19년 전 조회 1,939
19년 전 조회 3,210
19년 전 조회 3,121
19년 전 조회 2,232
19년 전 조회 1,778
19년 전 조회 2,825
19년 전 조회 2,890
19년 전 조회 4,003
19년 전 조회 1,966
19년 전 조회 2,617
19년 전 조회 2,329
19년 전 조회 3,456
19년 전 조회 1,413
19년 전 조회 1,479
19년 전 조회 1,761
19년 전 조회 2,202
19년 전 조회 1,829
19년 전 조회 1,690
19년 전 조회 2,100
19년 전 조회 2,197
19년 전 조회 4,952
19년 전 조회 2,322
19년 전 조회 3,189
19년 전 조회 2,638
19년 전 조회 2,402
19년 전 조회 4,694
19년 전 조회 2,550
19년 전 조회 2,399
19년 전 조회 1,936
19년 전 조회 1,719
19년 전 조회 3,343
19년 전 조회 2,317
19년 전 조회 6,148
19년 전 조회 2,009
19년 전 조회 1,893
19년 전 조회 2,695
19년 전 조회 1,794
19년 전 조회 2,269
19년 전 조회 2,100
19년 전 조회 3,549
19년 전 조회 2,567
19년 전 조회 2,737
19년 전 조회 4,359
19년 전 조회 3,538
19년 전 조회 2,300
19년 전 조회 4,287
19년 전 조회 3,260
19년 전 조회 4,125
19년 전 조회 1,988
19년 전 조회 2,202
19년 전 조회 2,130
19년 전 조회 3,336
19년 전 조회 2,708
19년 전 조회 3,497
19년 전 조회 2,670
19년 전 조회 2,510
19년 전 조회 2,333
19년 전 조회 2,226
19년 전 조회 2,115
19년 전 조회 4,243
19년 전 조회 2,663
🐛 버그신고