onclick 과 onkeyup을 하나의 변수에 동시에 사용하면 안되는 건가요?
라디오버튼으로 숫자를 선택하면 아래에 그래프로 표시되도록 구현했는데요,
이 부분은 잘 작동합니다.
그런데 여기에서 텍스트박스에 직접 입력하기를 함께 사용하려고 하는데 직접입력 부분이 전혀 작동을 하지 않습니다.
onclick 과 onkeyup을 하나의 변수에 동시에 사용하면 안되는 건가요?
무엇이 잘못된 건지 모르겠습니다.
-------------------------------------------------------------------------------------------------------
<!--라디오선택 부분-->
<input type="radio" name="wr_1" value="100" id="wr_1" onclick="changebar(this.value);">100<br>
<input type="radio" name="wr_1" value="200" id="wr_1" onclick="changebar(this.value);">200<br>
<input type="radio" name="wr_1" value="300" id="wr_1" onclick="changebar(this.value);">300<br>
<!--직접입력 부분-->
직접입력 : <input type="text" size=10 id="wr_1" name="wr_1" itemname="숫자" numeric value="" onkeyup="changebar(this.value);" onfocus="this.value='';">
<script type="text/javascript">
function changebar(score) {
limitmon = document.fviewcomment.wr_1.value;
if (limitmon < 0 || limitmon > 300 || limitmon.length < 1) {
alert("점수를 0~300점 사이로 점수를 주셔야 합니다.");
document.fviewcomment.wr_1.value= document.fviewcomment.wr_1.value.replace(/\D/g,'') ;
document.fviewcomment.wr_1.value = '';
document.getElementById("bar").width = '';
document.fviewcomment.wr_1.focus();
return false;
}
document.getElementById("bar").width = parseInt(score)*1;
}
</script>
<!--그래프로 나타나는 부분-->
<img src="../img/bar.jpg" id="bar" width="0" height="16">
-------------------------------------------------------------------------------------------------------
도움주시면 감사하겠습니다.
댓글 9개
13년 전
onkeypress 혹은 onkeydown이벤트를 이용해보세요.
13년 전
네 답변 감사합니다.
하지만 말씀하신대로 해보아도 안되는데요, 혹시 다른 문제가 있는 것 아닐지요?
하지만 말씀하신대로 해보아도 안되는데요, 혹시 다른 문제가 있는 것 아닐지요?
13년 전
javascript:changebar(this.value); 이렇게 해보심이... 이래도 안되면 지지 ㅠㅠ
13년 전
아니면 jquery로 $(object).keypress이벤트를 걸어도 됩니다.
13년 전
<!--라디오선택 부분-->
<input type="radio" name="wr_1" value="100" id="wr_1" onclick="changebar(this.value);">100<br>
<input type="radio" name="wr_1" value="200" id="wr_2" onclick="changebar(this.value);">200<br>
<input type="radio" name="wr_1" value="300" id="wr_3" onclick="changebar(this.value);">300<br>
<!--직접입력 부분-->
직접입력 : <input type="text" size=10 id="wr_4" name="wr_1" itemname="숫자" numeric value="" onkeyup="changebar(this.value);" onfocus="this.value='';">
<script type="text/javascript">
function changebar(score) {
limitmon = document.getElementById("wr_4").value;
if (limitmon < 0 || limitmon > 300 ) {
alert("점수를 0~300점 사이로 점수를 주셔야 합니다.");
limitmon.focus();
return false;
}
document.getElementById("bar").width = parseInt(score)*1;
}
</script>
<!--그래프로 나타나는 부분-->
<img src="../img/bar.jpg" id="bar" width="0" height="16">
name은 사람 이름하고 같습니다 즉 중복이 가능하나
id는 주민번호와 같아서 절대 중복이 있어서는 안됩니다
네임값으로 접근하실려면 배열로 접근해야 합니다
<input type="radio" name="wr_1" value="100" id="wr_1" onclick="changebar(this.value);">100<br>
<input type="radio" name="wr_1" value="200" id="wr_2" onclick="changebar(this.value);">200<br>
<input type="radio" name="wr_1" value="300" id="wr_3" onclick="changebar(this.value);">300<br>
<!--직접입력 부분-->
직접입력 : <input type="text" size=10 id="wr_4" name="wr_1" itemname="숫자" numeric value="" onkeyup="changebar(this.value);" onfocus="this.value='';">
<script type="text/javascript">
function changebar(score) {
limitmon = document.getElementById("wr_4").value;
if (limitmon < 0 || limitmon > 300 ) {
alert("점수를 0~300점 사이로 점수를 주셔야 합니다.");
limitmon.focus();
return false;
}
document.getElementById("bar").width = parseInt(score)*1;
}
</script>
<!--그래프로 나타나는 부분-->
<img src="../img/bar.jpg" id="bar" width="0" height="16">
name은 사람 이름하고 같습니다 즉 중복이 가능하나
id는 주민번호와 같아서 절대 중복이 있어서는 안됩니다
네임값으로 접근하실려면 배열로 접근해야 합니다
13년 전
오 예리하셔... ID가 같은걸 아무도 모르고 있었는데!!
13년 전
한수 배웁니다 ^^
13년 전
답변 정말 감사드립니다~~~
13년 전
자바스크립트 짜다가 해결되지 않거나 막히면 f12눌러 보세요
어디에서 오류가 있는지 기본적으로 볼수 있는 개발자 도구가 익스7이상부터는 제공합니다
어디에서 오류가 있는지 기본적으로 볼수 있는 개발자 도구가 익스7이상부터는 제공합니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6830 |
112211dd
|
11년 전 | 797 | |
| 6829 |
진짜다진짜가나타남
|
11년 전 | 1219 | |
| 6828 | 11년 전 | 832 | ||
| 6827 |
봉보로봉봉
|
11년 전 | 919 | |
| 6826 |
jinion
|
11년 전 | 832 | |
| 6825 | 11년 전 | 809 | ||
| 6824 |
yunkiri486
|
11년 전 | 730 | |
| 6823 |
2donggalbi
|
11년 전 | 860 | |
| 6822 | 11년 전 | 860 | ||
| 6821 | 11년 전 | 808 | ||
| 6820 | 11년 전 | 3113 | ||
| 6819 | 11년 전 | 1261 | ||
| 6818 | 11년 전 | 521 | ||
| 6817 |
|
11년 전 | 618 | |
| 6816 | 11년 전 | 2087 | ||
| 6815 | 11년 전 | 1223 | ||
| 6814 | 11년 전 | 872 | ||
| 6813 | 11년 전 | 621 | ||
| 6812 |
|
11년 전 | 992 | |
| 6811 | 11년 전 | 594 | ||
| 6810 | 11년 전 | 1548 | ||
| 6809 |
낚시가좋아
|
11년 전 | 1053 | |
| 6808 | 11년 전 | 450 | ||
| 6807 | 11년 전 | 780 | ||
| 6806 |
Unhappy
|
11년 전 | 1786 | |
| 6805 | 11년 전 | 1622 | ||
| 6804 | 11년 전 | 1137 | ||
| 6803 | 11년 전 | 579 | ||
| 6802 |
asdfg
|
11년 전 | 1149 | |
| 6801 |
아트귀농인
|
11년 전 | 512 | |
| 6800 | 11년 전 | 2567 | ||
| 6799 | 11년 전 | 1363 | ||
| 6798 | 11년 전 | 1477 | ||
| 6797 | 11년 전 | 636 | ||
| 6796 |
purple63
|
11년 전 | 436 | |
| 6795 | 11년 전 | 2641 | ||
| 6794 |
커네드커네드
|
11년 전 | 966 | |
| 6793 | 11년 전 | 415 | ||
| 6792 | 11년 전 | 2509 | ||
| 6791 | 11년 전 | 534 | ||
| 6790 | 11년 전 | 2267 | ||
| 6789 |
리아빌리티
|
11년 전 | 3107 | |
| 6788 | 11년 전 | 1348 | ||
| 6787 | 11년 전 | 684 | ||
| 6786 | 11년 전 | 395 | ||
| 6785 | 11년 전 | 725 | ||
| 6784 |
|
11년 전 | 855 | |
| 6783 | 11년 전 | 594 | ||
| 6782 | 11년 전 | 3662 | ||
| 6781 |
리아빌리티
|
11년 전 | 500 | |
| 6780 | 11년 전 | 542 | ||
| 6779 | 11년 전 | 494 | ||
| 6778 | 11년 전 | 4704 | ||
| 6777 |
바보온달123
|
11년 전 | 625 | |
| 6776 | 11년 전 | 936 | ||
| 6775 | 11년 전 | 739 | ||
| 6774 |
DANet
|
11년 전 | 647 | |
| 6773 | 11년 전 | 1562 | ||
| 6772 | 11년 전 | 1368 | ||
| 6771 | 11년 전 | 625 | ||
| 6770 | 11년 전 | 1165 | ||
| 6769 | 11년 전 | 962 | ||
| 6768 | 11년 전 | 696 | ||
| 6767 | 11년 전 | 591 | ||
| 6766 | 11년 전 | 1272 | ||
| 6765 |
크림나이트
|
11년 전 | 1006 | |
| 6764 | 11년 전 | 1558 | ||
| 6763 | 11년 전 | 2616 | ||
| 6762 | 11년 전 | 545 | ||
| 6761 |
|
11년 전 | 795 | |
| 6760 |
|
11년 전 | 721 | |
| 6759 | 11년 전 | 3354 | ||
| 6758 | 11년 전 | 1014 | ||
| 6757 | 11년 전 | 1276 | ||
| 6756 | 11년 전 | 900 | ||
| 6755 |
|
11년 전 | 577 | |
| 6754 |
|
11년 전 | 726 | |
| 6753 |
|
11년 전 | 1396 | |
| 6752 | 11년 전 | 614 | ||
| 6751 |
|
11년 전 | 658 | |
| 6750 |
|
11년 전 | 2031 | |
| 6749 | 11년 전 | 1223 | ||
| 6748 |
|
11년 전 | 1126 | |
| 6747 | 11년 전 | 1177 | ||
| 6746 | 11년 전 | 842 | ||
| 6745 |
|
11년 전 | 917 | |
| 6744 | 11년 전 | 857 | ||
| 6743 | 11년 전 | 1298 | ||
| 6742 | 11년 전 | 543 | ||
| 6741 |
Abilityarch
|
11년 전 | 614 | |
| 6740 | 11년 전 | 663 | ||
| 6739 |
leewin20
|
11년 전 | 1242 | |
| 6738 | 11년 전 | 515 | ||
| 6737 | 11년 전 | 1221 | ||
| 6736 | 11년 전 | 1263 | ||
| 6735 | 11년 전 | 558 | ||
| 6734 | 11년 전 | 1292 | ||
| 6733 |
RipperTNT
|
11년 전 | 1847 | |
| 6732 |
|
11년 전 | 1342 | |
| 6731 |
|
11년 전 | 1400 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기