펀스몬스터

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

· 19년 전 · 2327
<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,712
19년 전 조회 1,557
19년 전 조회 1,424
19년 전 조회 1,582
19년 전 조회 1,516
19년 전 조회 1,436
19년 전 조회 1,441
19년 전 조회 1,364
19년 전 조회 1,432
19년 전 조회 2,796
19년 전 조회 3,814
19년 전 조회 5,201
19년 전 조회 1,365
19년 전 조회 4,533
19년 전 조회 2,974
19년 전 조회 1,485
19년 전 조회 2,679
19년 전 조회 3,606
19년 전 조회 1,773
19년 전 조회 3,778
19년 전 조회 1,866
19년 전 조회 3,765
19년 전 조회 3,414
19년 전 조회 4,193
19년 전 조회 4,038
19년 전 조회 1,868
19년 전 조회 1,835
19년 전 조회 4,265
19년 전 조회 2,668
19년 전 조회 2,535
19년 전 조회 2,391
19년 전 조회 1,966
19년 전 조회 2,555
19년 전 조회 2,187
19년 전 조회 1,836
19년 전 조회 1,957
19년 전 조회 1,430
19년 전 조회 1,683
19년 전 조회 2,825
19년 전 조회 1,938
19년 전 조회 3,210
19년 전 조회 3,121
19년 전 조회 2,232
19년 전 조회 1,777
19년 전 조회 2,824
19년 전 조회 2,890
19년 전 조회 4,002
19년 전 조회 1,966
19년 전 조회 2,616
19년 전 조회 2,328
19년 전 조회 3,456
19년 전 조회 1,413
19년 전 조회 1,479
19년 전 조회 1,760
19년 전 조회 2,201
19년 전 조회 1,828
19년 전 조회 1,690
19년 전 조회 2,099
19년 전 조회 2,196
19년 전 조회 4,951
19년 전 조회 2,320
19년 전 조회 3,187
19년 전 조회 2,636
19년 전 조회 2,401
19년 전 조회 4,693
19년 전 조회 2,549
19년 전 조회 2,398
19년 전 조회 1,936
19년 전 조회 1,718
19년 전 조회 3,343
19년 전 조회 2,316
19년 전 조회 6,148
19년 전 조회 2,009
19년 전 조회 1,893
19년 전 조회 2,694
19년 전 조회 1,794
19년 전 조회 2,269
19년 전 조회 2,100
19년 전 조회 3,549
19년 전 조회 2,566
19년 전 조회 2,737
19년 전 조회 4,358
19년 전 조회 3,538
19년 전 조회 2,300
19년 전 조회 4,286
19년 전 조회 3,258
19년 전 조회 4,123
19년 전 조회 1,986
19년 전 조회 2,200
19년 전 조회 2,129
19년 전 조회 3,335
19년 전 조회 2,706
19년 전 조회 3,497
19년 전 조회 2,670
19년 전 조회 2,510
19년 전 조회 2,333
19년 전 조회 2,226
19년 전 조회 2,115
19년 전 조회 4,243
19년 전 조회 2,663
🐛 버그신고