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이상부터는 제공합니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5330 | 13년 전 | 768 | ||
| 5329 | 13년 전 | 705 | ||
| 5328 | 13년 전 | 637 | ||
| 5327 | 13년 전 | 881 | ||
| 5326 |
downmix
|
13년 전 | 1116 | |
| 5325 |
techer
|
13년 전 | 3141 | |
| 5324 |
techer
|
13년 전 | 965 | |
| 5323 | 13년 전 | 1175 | ||
| 5322 |
김준수사랑
|
13년 전 | 892 | |
| 5321 |
다케미카코
|
13년 전 | 752 | |
| 5320 |
|
13년 전 | 995 | |
| 5319 |
한번잘해보자
|
13년 전 | 1004 | |
| 5318 |
|
13년 전 | 1272 | |
| 5317 |
techer
|
13년 전 | 2705 | |
| 5316 |
techer
|
13년 전 | 3143 | |
| 5315 | 13년 전 | 1172 | ||
| 5314 |
티즈코리아
|
13년 전 | 1227 | |
| 5313 | 13년 전 | 701 | ||
| 5312 |
|
13년 전 | 1871 | |
| 5311 |
innis
|
13년 전 | 771 | |
| 5310 | 13년 전 | 857 | ||
| 5309 |
changho
|
13년 전 | 660 | |
| 5308 |
|
13년 전 | 1363 | |
| 5307 |
|
13년 전 | 800 | |
| 5306 | 13년 전 | 1183 | ||
| 5305 |
세상속으로
|
13년 전 | 1162 | |
| 5304 | 13년 전 | 666 | ||
| 5303 | 13년 전 | 2254 | ||
| 5302 | 13년 전 | 1389 | ||
| 5301 | 13년 전 | 1106 | ||
| 5300 |
프로프리랜서
|
13년 전 | 1084 | |
| 5299 | 13년 전 | 872 | ||
| 5298 | 13년 전 | 680 | ||
| 5297 |
나랑사귈래
|
13년 전 | 610 | |
| 5296 | 13년 전 | 1338 | ||
| 5295 | 13년 전 | 1119 | ||
| 5294 | 13년 전 | 729 | ||
| 5293 |
|
13년 전 | 5820 | |
| 5292 |
|
13년 전 | 792 | |
| 5291 | 13년 전 | 613 | ||
| 5290 | 13년 전 | 554 | ||
| 5289 | 13년 전 | 653 | ||
| 5288 | 13년 전 | 1170 | ||
| 5287 | 13년 전 | 761 | ||
| 5286 | 13년 전 | 972 | ||
| 5285 | 13년 전 | 1324 | ||
| 5284 |
미스홍당무
|
13년 전 | 858 | |
| 5283 |
basketball
|
13년 전 | 1758 | |
| 5282 | 13년 전 | 787 | ||
| 5281 |
|
13년 전 | 796 | |
| 5280 | 13년 전 | 1214 | ||
| 5279 | 13년 전 | 1384 | ||
| 5278 |
크라이스트
|
13년 전 | 2048 | |
| 5277 |
|
13년 전 | 732 | |
| 5276 |
그누보드환자이송
|
13년 전 | 789 | |
| 5275 | 13년 전 | 704 | ||
| 5274 | 13년 전 | 1372 | ||
| 5273 | 13년 전 | 2004 | ||
| 5272 | 13년 전 | 1120 | ||
| 5271 | 13년 전 | 1434 | ||
| 5270 | 13년 전 | 808 | ||
| 5269 | 13년 전 | 524 | ||
| 5268 | 13년 전 | 658 | ||
| 5267 | 13년 전 | 1188 | ||
| 5266 | 13년 전 | 1855 | ||
| 5265 | 13년 전 | 1626 | ||
| 5264 |
크라이스트
|
13년 전 | 1205 | |
| 5263 |
|
13년 전 | 1263 | |
| 5262 |
제이티37
|
13년 전 | 585 | |
| 5261 |
|
13년 전 | 777 | |
| 5260 |
quenya
|
13년 전 | 2070 | |
| 5259 | 13년 전 | 707 | ||
| 5258 | 13년 전 | 730 | ||
| 5257 |
크라이스트
|
13년 전 | 4595 | |
| 5256 | 13년 전 | 1251 | ||
| 5255 | 13년 전 | 3258 | ||
| 5254 |
|
13년 전 | 704 | |
| 5253 | 13년 전 | 768 | ||
| 5252 | 13년 전 | 768 | ||
| 5251 | 13년 전 | 719 | ||
| 5250 |
dudn1114
|
13년 전 | 1293 | |
| 5249 | 13년 전 | 672 | ||
| 5248 | 13년 전 | 740 | ||
| 5247 | 13년 전 | 2081 | ||
| 5246 | 13년 전 | 506 | ||
| 5245 | 13년 전 | 2194 | ||
| 5244 | 13년 전 | 1456 | ||
| 5243 |
|
13년 전 | 971 | |
| 5242 | 13년 전 | 769 | ||
| 5241 | 13년 전 | 1850 | ||
| 5240 |
|
13년 전 | 506 | |
| 5239 | 13년 전 | 1035 | ||
| 5238 | 13년 전 | 1223 | ||
| 5237 | 13년 전 | 1117 | ||
| 5236 | 13년 전 | 587 | ||
| 5235 |
|
13년 전 | 765 | |
| 5234 |
뭐먹고살지ㅠ
|
13년 전 | 1032 | |
| 5233 | 13년 전 | 3597 | ||
| 5232 | 13년 전 | 3138 | ||
| 5231 | 13년 전 | 3729 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기