만약에 셀렉트 값 또는 라디오 버튼 값을 수정하면 값이 증가를 합니다. 채택완료
alexseo
11년 전
조회 5,360
아래 소스는 합계를 내는 소스입니다.
체크박스는 문제가 없는데,
셀렉트 와 라디오 버튼을 선택을 하면 처음에는 선택값이 나오는데
만약에 셀렉트 값 또는 라디오 버튼 값을 수정하면 값이 증가를 합니다.
값이 수정(변경)한 값으로 대체가 되어야 하는데 증가를 하는데요.
어떻게 해결을 해야할지요.
감사합니다.
|
| |
|
if ($write[wr_2] == 16000) echo "checked";?> 박스광스 | 6,000 p/30일 1 |
|
1000원
2000원 | 6,000 p/30일 1 |
| 포인트합계 |
function checkChoice(whichbox) {
with (whichbox.form) {
if (whichbox.checked == false) {
hiddenwr_10.value = parseInt(hiddenwr_10.value) - parseInt(whichbox.value);
} else {
hiddenwr_10.value = parseInt(hiddenwr_10.value) + parseInt(whichbox.value);
}
return(formatCurrency(hiddenwr_10.value));
}
}
function formatCurrency(num) {
num = num.toString().replace(/$|,/g,'');
if(isNaN(num)) { num = "0"; }
cents = Math.floor((num*100+0.5)%100);
num = Math.floor((num*100+0.5)/100).toString();
if(cents < 10) {
cents = "0" + cents;
}
return (num);
}
댓글을 작성하려면 로그인이 필요합니다.
답변 2개
채택된 답변
+20 포인트
11년 전
</div>
<div><select name='wr_1' class='ed' itemname='필수선택' onChange="wr1=this.value;sum()" required></div>
<div><span style="font-size: 10pt; line-height: 1.5">
</span></div>
<div><span style="font-size: 10pt; line-height: 1.5"><input type="checkbox" name="wr_2" value="16000" onClick="wr2= this.checked ? this.value : 0;sum();" ></span></div>
<div><span style="font-size: 10pt; line-height: 1.5">
</span></div>
<div><span style="font-size: 10pt; line-height: 1.5"><input type=radio name="wr_3" value="1000" onChange="wr3=this.value;sum();"></span></div>
<div><input type=radio name="wr_3" value="2000" onChange="wr3=this.value;sum();"></div>
<div><span style="font-size: 10pt; line-height: 1.5">
</span></div>
<div><span style="font-size: 10pt; line-height: 1.5"><script></span></div>
<div>var wr1 = 0, wr2 = 0, wr3 = 0;</div>
<div>function sum() { document.forms.fwrite.elements.wr_10.value = parseInt(wr1) + parseInt(wr2) + parseInt(wr3);}</div>
<div></script></div>
<div>
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인