textarea에 입력된 길이만큼 게이지로 표현
<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>
<!--
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>
게시판 목록
퍼블리셔팁
퍼블리싱과 관련된 유용한 정보를 공유하세요.
질문은 상단의 QA에서 해주시기 바랍니다.
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 107 | HTML |
홀로남은자
|
19년 전 | 3335 | |
| 106 | HTML | 19년 전 | 3219 | ||
| 105 | HTML |
그레이스웹
|
19년 전 | 4948 | |
| 104 | HTML |
|
19년 전 | 6288 | |
| 103 | HTML |
|
19년 전 | 5267 | |
| 102 | HTML |
|
19년 전 | 4624 | |
| 101 | HTML |
|
19년 전 | 3437 | |
| 100 | HTML |
|
19년 전 | 6191 | |
| 99 | HTML |
|
19년 전 | 5025 | |
| 98 | HTML |
|
19년 전 | 3447 | |
| 97 | HTML |
|
19년 전 | 4439 | |
| 96 | HTML | 19년 전 | 6878 | ||
| 95 | HTML | 19년 전 | 4332 | ||
| 94 | HTML | 19년 전 | 3217 | ||
| 93 | HTML | 19년 전 | 5760 | ||
| 92 | HTML | 19년 전 | 4153 | ||
| 91 | HTML |
|
19년 전 | 5182 | |
| 90 | HTML |
|
19년 전 | 3242 | |
| 89 | HTML |
|
19년 전 | 3163 | |
| 88 | HTML |
|
19년 전 | 3630 | |
| 87 | HTML | 19년 전 | 5165 | ||
| 86 | HTML | 19년 전 | 4810 | ||
| 85 | HTML | 19년 전 | 4140 | ||
| 84 | HTML |
|
19년 전 | 3493 | |
| 83 | HTML |
|
19년 전 | 3153 | |
| 82 | HTML | 19년 전 | 4918 | ||
| 81 | HTML |
|
19년 전 | 4132 | |
| 80 | HTML | 19년 전 | 4454 | ||
| 79 | HTML | 19년 전 | 3583 | ||
| 78 | HTML |
|
19년 전 | 4920 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기