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이상부터는 제공합니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 39 | ||
| 8229 | 9년 전 | 47 | ||
| 8228 |
커네드커네드
|
9년 전 | 92 | |
| 8227 | 9년 전 | 100 | ||
| 8226 | 9년 전 | 139 | ||
| 8225 | 9년 전 | 127 | ||
| 8224 | 9년 전 | 122 | ||
| 8223 | 9년 전 | 82 | ||
| 8222 |
|
9년 전 | 160 | |
| 8221 | 9년 전 | 74 | ||
| 8220 | 9년 전 | 67 | ||
| 8219 | 9년 전 | 73 | ||
| 8218 | 9년 전 | 107 | ||
| 8217 |
star3840
|
9년 전 | 87 | |
| 8216 | 9년 전 | 129 | ||
| 8215 | 9년 전 | 82 | ||
| 8214 | 9년 전 | 201 | ||
| 8213 | 9년 전 | 138 | ||
| 8212 | 9년 전 | 50 | ||
| 8211 | 9년 전 | 213 | ||
| 8210 | 9년 전 | 209 | ||
| 8209 | 9년 전 | 313 | ||
| 8208 | 9년 전 | 179 | ||
| 8207 | 9년 전 | 196 | ||
| 8206 |
|
9년 전 | 154 | |
| 8205 | 9년 전 | 141 | ||
| 8204 | 9년 전 | 106 | ||
| 8203 | 9년 전 | 196 | ||
| 8202 | 9년 전 | 121 | ||
| 8201 | 9년 전 | 160 | ||
| 8200 | 9년 전 | 126 | ||
| 8199 | 9년 전 | 173 | ||
| 8198 | 9년 전 | 151 | ||
| 8197 | 9년 전 | 130 | ||
| 8196 | 9년 전 | 506 | ||
| 8195 | 9년 전 | 132 | ||
| 8194 | 9년 전 | 262 | ||
| 8193 | 9년 전 | 128 | ||
| 8192 | 9년 전 | 152 | ||
| 8191 | 9년 전 | 111 | ||
| 8190 | 9년 전 | 107 | ||
| 8189 | 9년 전 | 161 | ||
| 8188 | 9년 전 | 98 | ||
| 8187 | 9년 전 | 118 | ||
| 8186 | 9년 전 | 126 | ||
| 8185 | 9년 전 | 284 | ||
| 8184 | 9년 전 | 80 | ||
| 8183 | 9년 전 | 305 | ||
| 8182 | 9년 전 | 134 | ||
| 8181 | 9년 전 | 104 | ||
| 8180 | 9년 전 | 670 | ||
| 8179 | 9년 전 | 470 | ||
| 8178 | 9년 전 | 275 | ||
| 8177 |
kiplayer
|
9년 전 | 276 | |
| 8176 | 9년 전 | 321 | ||
| 8175 | 9년 전 | 201 | ||
| 8174 | 9년 전 | 208 | ||
| 8173 | 9년 전 | 320 | ||
| 8172 | 9년 전 | 163 | ||
| 8171 | 9년 전 | 157 | ||
| 8170 | 9년 전 | 271 | ||
| 8169 |
커네드커네드
|
9년 전 | 236 | |
| 8168 | 9년 전 | 289 | ||
| 8167 | 9년 전 | 298 | ||
| 8166 | 9년 전 | 209 | ||
| 8165 | 9년 전 | 144 | ||
| 8164 | 9년 전 | 273 | ||
| 8163 | 9년 전 | 263 | ||
| 8162 | 9년 전 | 269 | ||
| 8161 | 9년 전 | 264 | ||
| 8160 |
|
9년 전 | 463 | |
| 8159 | 9년 전 | 378 | ||
| 8158 | 9년 전 | 192 | ||
| 8157 | 9년 전 | 336 | ||
| 8156 | 9년 전 | 250 | ||
| 8155 | 9년 전 | 231 | ||
| 8154 |
00년생용띠
|
9년 전 | 574 | |
| 8153 | 9년 전 | 200 | ||
| 8152 |
|
9년 전 | 377 | |
| 8151 | 9년 전 | 379 | ||
| 8150 | 9년 전 | 470 | ||
| 8149 |
Jangfolk
|
9년 전 | 312 | |
| 8148 | 9년 전 | 145 | ||
| 8147 | 9년 전 | 349 | ||
| 8146 | 9년 전 | 406 | ||
| 8145 | 9년 전 | 329 | ||
| 8144 | 9년 전 | 298 | ||
| 8143 | 9년 전 | 152 | ||
| 8142 | 9년 전 | 400 | ||
| 8141 | 9년 전 | 350 | ||
| 8140 | 9년 전 | 897 | ||
| 8139 | 9년 전 | 224 | ||
| 8138 |
전갈자리남자
|
9년 전 | 364 | |
| 8137 | 9년 전 | 343 | ||
| 8136 | 9년 전 | 709 | ||
| 8135 |
|
9년 전 | 758 | |
| 8134 |
PlayPixel
|
9년 전 | 470 | |
| 8133 |
|
9년 전 | 412 | |
| 8132 | 9년 전 | 428 | ||
| 8131 | 9년 전 | 781 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기