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이상부터는 제공합니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6930 |
SOFTA
|
11년 전 | 5986 | |
| 6929 |
|
11년 전 | 1603 | |
| 6928 | 11년 전 | 1762 | ||
| 6927 | 11년 전 | 1788 | ||
| 6926 | 11년 전 | 1887 | ||
| 6925 | 11년 전 | 2279 | ||
| 6924 | 11년 전 | 3877 | ||
| 6923 | 11년 전 | 2279 | ||
| 6922 |
level999
|
11년 전 | 1045 | |
| 6921 | 11년 전 | 822 | ||
| 6920 | 11년 전 | 963 | ||
| 6919 | 11년 전 | 1074 | ||
| 6918 | 11년 전 | 1316 | ||
| 6917 | 11년 전 | 15430 | ||
| 6916 | 11년 전 | 1429 | ||
| 6915 | 11년 전 | 590 | ||
| 6914 | 11년 전 | 623 | ||
| 6913 | 11년 전 | 882 | ||
| 6912 | 11년 전 | 3134 | ||
| 6911 |
사랑해요79
|
11년 전 | 973 | |
| 6910 | 11년 전 | 750 | ||
| 6909 | 11년 전 | 786 | ||
| 6908 | 11년 전 | 648 | ||
| 6907 | 11년 전 | 835 | ||
| 6906 | 11년 전 | 1592 | ||
| 6905 | 11년 전 | 576 | ||
| 6904 | 11년 전 | 1015 | ||
| 6903 | 11년 전 | 1685 | ||
| 6902 |
2donggalbi
|
11년 전 | 525 | |
| 6901 | 11년 전 | 1401 | ||
| 6900 | 11년 전 | 725 | ||
| 6899 | 11년 전 | 867 | ||
| 6898 |
열라뽕똬이
|
11년 전 | 1319 | |
| 6897 |
this1mg
|
11년 전 | 1618 | |
| 6896 |
sbdossb
|
11년 전 | 587 | |
| 6895 |
봉보로봉봉
|
11년 전 | 1162 | |
| 6894 |
똘똘이스머츠
|
11년 전 | 501 | |
| 6893 |
네이비컬러
|
11년 전 | 3647 | |
| 6892 | 11년 전 | 1081 | ||
| 6891 |
네이비컬러
|
11년 전 | 1328 | |
| 6890 | 11년 전 | 1153 | ||
| 6889 | 11년 전 | 595 | ||
| 6888 | 11년 전 | 731 | ||
| 6887 | 11년 전 | 623 | ||
| 6886 | 11년 전 | 5063 | ||
| 6885 | 11년 전 | 562 | ||
| 6884 |
asfasdfd235
|
11년 전 | 593 | |
| 6883 | 11년 전 | 3057 | ||
| 6882 | 11년 전 | 953 | ||
| 6881 | 11년 전 | 4446 | ||
| 6880 | 11년 전 | 1827 | ||
| 6879 |
퍼블리셔지노군
|
11년 전 | 2639 | |
| 6878 | 11년 전 | 573 | ||
| 6877 | 11년 전 | 589 | ||
| 6876 | 11년 전 | 1453 | ||
| 6875 | 11년 전 | 636 | ||
| 6874 | 11년 전 | 1609 | ||
| 6873 | 11년 전 | 1610 | ||
| 6872 | 11년 전 | 4467 | ||
| 6871 |
Abilityarch
|
11년 전 | 974 | |
| 6870 | 11년 전 | 2135 | ||
| 6869 | 11년 전 | 1416 | ||
| 6868 | 11년 전 | 1463 | ||
| 6867 | 11년 전 | 1532 | ||
| 6866 | 11년 전 | 751 | ||
| 6865 | 11년 전 | 1625 | ||
| 6864 | 11년 전 | 483 | ||
| 6863 | 11년 전 | 3757 | ||
| 6862 | 11년 전 | 1856 | ||
| 6861 | 11년 전 | 1654 | ||
| 6860 | 11년 전 | 1313 | ||
| 6859 |
cityman
|
11년 전 | 6819 | |
| 6858 | 11년 전 | 1277 | ||
| 6857 |
의정부아줌마
|
11년 전 | 875 | |
| 6856 | 11년 전 | 2379 | ||
| 6855 | 11년 전 | 1709 | ||
| 6854 | 11년 전 | 837 | ||
| 6853 | 11년 전 | 1213 | ||
| 6852 | 11년 전 | 2603 | ||
| 6851 | 11년 전 | 1980 | ||
| 6850 | 11년 전 | 1804 | ||
| 6849 | 11년 전 | 2095 | ||
| 6848 | 11년 전 | 2373 | ||
| 6847 | 11년 전 | 3150 | ||
| 6846 | 11년 전 | 2727 | ||
| 6845 | 11년 전 | 2809 | ||
| 6844 | 11년 전 | 3533 | ||
| 6843 | 11년 전 | 3278 | ||
| 6842 |
아트291
|
11년 전 | 698 | |
| 6841 | 11년 전 | 4174 | ||
| 6840 | 11년 전 | 5192 | ||
| 6839 | 11년 전 | 903 | ||
| 6838 |
|
11년 전 | 2102 | |
| 6837 | 11년 전 | 1286 | ||
| 6836 |
netdf
|
11년 전 | 621 | |
| 6835 |
|
11년 전 | 1015 | |
| 6834 | 11년 전 | 684 | ||
| 6833 |
|
11년 전 | 2693 | |
| 6832 |
울산굿모닝
|
11년 전 | 1673 | |
| 6831 |
|
11년 전 | 676 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기