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이상부터는 제공합니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5130 | 13년 전 | 761 | ||
| 5129 | 13년 전 | 1765 | ||
| 5128 | 13년 전 | 932 | ||
| 5127 | 13년 전 | 514 | ||
| 5126 | 13년 전 | 763 | ||
| 5125 | 13년 전 | 1371 | ||
| 5124 | 13년 전 | 842 | ||
| 5123 | 13년 전 | 477 | ||
| 5122 | 13년 전 | 1000 | ||
| 5121 |
|
13년 전 | 1383 | |
| 5120 | 13년 전 | 507 | ||
| 5119 | 13년 전 | 484 | ||
| 5118 | 13년 전 | 412 | ||
| 5117 | 13년 전 | 726 | ||
| 5116 | 13년 전 | 469 | ||
| 5115 | 13년 전 | 918 | ||
| 5114 | 13년 전 | 940 | ||
| 5113 |
cookieyou
|
13년 전 | 1355 | |
| 5112 | 13년 전 | 538 | ||
| 5111 | 13년 전 | 829 | ||
| 5110 | 13년 전 | 4441 | ||
| 5109 | 13년 전 | 1062 | ||
| 5108 | 13년 전 | 421 | ||
| 5107 | 13년 전 | 494 | ||
| 5106 | 13년 전 | 642 | ||
| 5105 | 13년 전 | 1107 | ||
| 5104 | 13년 전 | 415 | ||
| 5103 |
프로프리랜서
|
13년 전 | 1350 | |
| 5102 | 13년 전 | 1591 | ||
| 5101 | 13년 전 | 465 | ||
| 5100 | 13년 전 | 376 | ||
| 5099 | 13년 전 | 524 | ||
| 5098 | 13년 전 | 2138 | ||
| 5097 | 13년 전 | 384 | ||
| 5096 | 13년 전 | 536 | ||
| 5095 | 13년 전 | 388 | ||
| 5094 | 13년 전 | 398 | ||
| 5093 | 13년 전 | 882 | ||
| 5092 | 13년 전 | 1068 | ||
| 5091 | 13년 전 | 427 | ||
| 5090 | 13년 전 | 519 | ||
| 5089 | 13년 전 | 964 | ||
| 5088 | 13년 전 | 420 | ||
| 5087 | 13년 전 | 1176 | ||
| 5086 | 13년 전 | 1509 | ||
| 5085 |
|
13년 전 | 3944 | |
| 5084 |
alexseo
|
13년 전 | 925 | |
| 5083 | 13년 전 | 1131 | ||
| 5082 | 13년 전 | 608 | ||
| 5081 | 13년 전 | 530 | ||
| 5080 | 13년 전 | 612 | ||
| 5079 | 13년 전 | 991 | ||
| 5078 | 13년 전 | 2210 | ||
| 5077 | 13년 전 | 684 | ||
| 5076 |
몰보는거야
|
13년 전 | 1696 | |
| 5075 |
|
13년 전 | 1775 | |
| 5074 | 13년 전 | 2023 | ||
| 5073 |
|
13년 전 | 776 | |
| 5072 |
프로프리랜서
|
13년 전 | 1045 | |
| 5071 |
프로프리랜서
|
13년 전 | 767 | |
| 5070 |
프로프리랜서
|
13년 전 | 878 | |
| 5069 |
뭐먹고살지ㅠ
|
13년 전 | 794 | |
| 5068 |
danielle
|
13년 전 | 655 | |
| 5067 | 13년 전 | 766 | ||
| 5066 | 13년 전 | 837 | ||
| 5065 | 13년 전 | 909 | ||
| 5064 | 13년 전 | 1723 | ||
| 5063 | 13년 전 | 443 | ||
| 5062 | 13년 전 | 833 | ||
| 5061 | 13년 전 | 586 | ||
| 5060 | 13년 전 | 395 | ||
| 5059 |
senseme
|
13년 전 | 868 | |
| 5058 | 13년 전 | 2883 | ||
| 5057 | 13년 전 | 1942 | ||
| 5056 | 13년 전 | 1499 | ||
| 5055 | 13년 전 | 456 | ||
| 5054 |
senseme
|
13년 전 | 1072 | |
| 5053 |
senseme
|
13년 전 | 1912 | |
| 5052 |
senseme
|
13년 전 | 1039 | |
| 5051 |
senseme
|
13년 전 | 1061 | |
| 5050 |
senseme
|
13년 전 | 807 | |
| 5049 |
senseme
|
13년 전 | 992 | |
| 5048 | 13년 전 | 1995 | ||
| 5047 | 13년 전 | 498 | ||
| 5046 |
우렁찬우렁이
|
13년 전 | 890 | |
| 5045 |
크라이스트
|
13년 전 | 2162 | |
| 5044 | 13년 전 | 974 | ||
| 5043 | 13년 전 | 537 | ||
| 5042 | 13년 전 | 983 | ||
| 5041 |
|
13년 전 | 815 | |
| 5040 |
스마일라니
|
13년 전 | 881 | |
| 5039 | 13년 전 | 1154 | ||
| 5038 | 13년 전 | 1931 | ||
| 5037 | 13년 전 | 1050 | ||
| 5036 |
cookieyou
|
13년 전 | 1406 | |
| 5035 | 13년 전 | 502 | ||
| 5034 | 13년 전 | 566 | ||
| 5033 | 13년 전 | 490 | ||
| 5032 | 13년 전 | 439 | ||
| 5031 | 13년 전 | 733 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기