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이상부터는 제공합니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 330 |
prosper
|
20년 전 | 2285 | |
| 329 |
prosper
|
20년 전 | 1914 | |
| 328 |
prosper
|
20년 전 | 1707 | |
| 327 | 20년 전 | 3774 | ||
| 326 | 20년 전 | 4860 | ||
| 325 |
hwatta
|
20년 전 | 2486 | |
| 324 |
|
20년 전 | 3148 | |
| 323 | 20년 전 | 5869 | ||
| 322 |
hwatta
|
20년 전 | 2855 | |
| 321 |
hwatta
|
20년 전 | 2326 | |
| 320 |
yesmoa
|
20년 전 | 4578 | |
| 319 | 20년 전 | 2692 | ||
| 318 | 20년 전 | 2243 | ||
| 317 |
kyodon
|
20년 전 | 2765 | |
| 316 | 20년 전 | 2587 | ||
| 315 |
|
20년 전 | 2888 | |
| 314 |
|
20년 전 | 3345 | |
| 313 |
|
20년 전 | 2651 | |
| 312 |
yesmoa
|
20년 전 | 4725 | |
| 311 | 20년 전 | 3281 | ||
| 310 |
홀로남은자
|
20년 전 | 4571 | |
| 309 | 20년 전 | 3010 | ||
| 308 | 20년 전 | 4141 | ||
| 307 | 20년 전 | 4377 | ||
| 306 | 20년 전 | 7039 | ||
| 305 | 20년 전 | 3872 | ||
| 304 | 20년 전 | 2774 | ||
| 303 |
크리스탈처럼
|
20년 전 | 4409 | |
| 302 | 20년 전 | 2210 | ||
| 301 |
|
20년 전 | 4328 | |
| 300 | 20년 전 | 3813 | ||
| 299 | 20년 전 | 2623 | ||
| 298 | 20년 전 | 4837 | ||
| 297 |
|
20년 전 | 2531 | |
| 296 | 20년 전 | 4536 | ||
| 295 | 20년 전 | 3573 | ||
| 294 | 20년 전 | 3596 | ||
| 293 | 20년 전 | 3821 | ||
| 292 | 20년 전 | 3215 | ||
| 291 |
yesmoa
|
20년 전 | 5946 | |
| 290 | 20년 전 | 2942 | ||
| 289 | 20년 전 | 5865 | ||
| 288 |
|
20년 전 | 2383 | |
| 287 |
|
20년 전 | 1814 | |
| 286 |
|
20년 전 | 2152 | |
| 285 |
|
20년 전 | 3545 | |
| 284 |
|
20년 전 | 2039 | |
| 283 |
|
20년 전 | 4405 | |
| 282 | 20년 전 | 3383 | ||
| 281 |
|
20년 전 | 2216 | |
| 280 |
|
20년 전 | 7812 | |
| 279 | 20년 전 | 5562 | ||
| 278 | 20년 전 | 2999 | ||
| 277 |
|
20년 전 | 5574 | |
| 276 | 20년 전 | 2363 | ||
| 275 | 20년 전 | 2614 | ||
| 274 | 20년 전 | 2398 | ||
| 273 | 20년 전 | 2230 | ||
| 272 | 20년 전 | 2157 | ||
| 271 | 20년 전 | 2615 | ||
| 270 | 20년 전 | 2647 | ||
| 269 | 20년 전 | 2491 | ||
| 268 | 20년 전 | 2694 | ||
| 267 | 20년 전 | 2381 | ||
| 266 | 20년 전 | 2571 | ||
| 265 | 20년 전 | 3516 | ||
| 264 |
|
20년 전 | 5376 | |
| 263 |
|
20년 전 | 3736 | |
| 262 | 20년 전 | 3197 | ||
| 261 |
허저비
|
20년 전 | 5943 | |
| 260 |
|
20년 전 | 5722 | |
| 259 | 20년 전 | 4147 | ||
| 258 | 20년 전 | 2381 | ||
| 257 | 20년 전 | 3200 | ||
| 256 | 20년 전 | 1914 | ||
| 255 | 20년 전 | 1584 | ||
| 254 | 20년 전 | 3156 | ||
| 253 | 20년 전 | 3550 | ||
| 252 | 20년 전 | 5131 | ||
| 251 | 20년 전 | 5825 | ||
| 250 | 20년 전 | 3682 | ||
| 249 | 20년 전 | 5028 | ||
| 248 | 20년 전 | 3296 | ||
| 247 | 20년 전 | 3654 | ||
| 246 |
|
20년 전 | 7965 | |
| 245 |
|
20년 전 | 5925 | |
| 244 | 20년 전 | 4498 | ||
| 243 |
|
20년 전 | 4072 | |
| 242 | 20년 전 | 2798 | ||
| 241 | 20년 전 | 2746 | ||
| 240 | 20년 전 | 2383 | ||
| 239 | 20년 전 | 1673 | ||
| 238 |
아우겐나이스
|
20년 전 | 2283 | |
| 237 |
email
|
20년 전 | 3695 | |
| 236 | 20년 전 | 4174 | ||
| 235 | 20년 전 | 10474 | ||
| 234 | 20년 전 | 5082 | ||
| 233 | 20년 전 | 3385 | ||
| 232 | 20년 전 | 3225 | ||
| 231 | 20년 전 | 3861 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기