DB 문의 드립니다.
본문
위와 같이 wr_1 + wr_3 + wr_5 + wr_7 = wr_9 으로 나오게 하려고 하는데요.
더하기에서 구해진 값이 wr_9 로 저장되게 하려면 어떻게 해야 하나요?
답변 3
<input type="text" name="wr_1" id="wr_1" value="">
<input type="text" name="wr_3" id="wr_3" value="">
<input type="text" name="wr_5" id="wr_5" value="">
<input type="text" name="wr_7" id="wr_7" value="">
<input type="text" name="wr_9" id="wr_9" value="">
<button id="btn">계산</button>
<script>
$('#btn').click(function(){
var sum = parseInt($('#wr_1').val()) + parseInt($('#wr_3').val()) + parseInt($('#wr_5').val()) + parseInt($('#wr_7').val());
$('#wr_9').val(sum);
});
</script>
죄송합니다. 제가 좀 헛갈리게 질문 한거 같으네요 ..
wr_1 + wr_3 + wr_5 + wr_7 이 더해진 값이 wr_9으로 저장되게 했으면 합니다.
시키시는대로 해봐도 안되네요.. ㅠㅠ 뭐가 잘못된건지..
<table>
<tr>
<td>구분</td><td>상품가</td><td>인원</td><td>소계</td>
</tr>
<tr>
<td>성인</td>
<td><input type="num" name="wr_8" value="<?php echo $wr_8 ?>" id="wr_8" class="frm_input" size="10"></td>
<td><input type="num" name="wr_9" value="<?php echo $wr_9 ?>" id="wr_9" class="frm_input" size="2"></td>
<td><?php echo number_format($wr_8 * $wr_9) ?></td>
</tr>
<tr>
<td>아동1</td>
<td><input type="num" name="wr_10" value="<?php echo $wr_10 ?>" id="wr_10" class="frm_input" size="10"></td>
<td><input type="num" name="wr_11" value="<?php echo $wr_11 ?>" id="wr_11" class="frm_input" size="2"></td>
<td><?php echo number_format($wr_10 * $wr_11) ?></td>
</tr>
<tr>
<td>아동2</td>
<td><input type="num" name="wr_12" value="<?php echo $wr_12 ?>" id="wr_12" class="frm_input" size="10"></td>
<td><input type="num" name="wr_13" value="<?php echo $wr_13 ?>" id="wr_13" class="frm_input" size="2"></td>
<td><?php echo number_format($wr_12 * $wr_13) ?></td>
</tr>
<tr>
<td>유아</td>
<td><input type="num" name="wr_14" value="<?php echo $wr_14 ?>" id="wr_14" class="frm_input" size="10"></td>
<td><input type="num" name="wr_15" value="<?php echo $wr_15 ?>" id="wr_15" class="frm_input" size="2"></td>
<td><?php echo number_format($wr_14 * $wr_15) ?></td>
</tr>
<tr>
<td>추가금액</td>
<td colspan=2><input type="text" name="wr_17" value="<?php echo $wr_17 ?>" id="wr_17" class="frm_input" size="20"></td>
<td><input type="num" name="wr_16" value="<?php echo $wr_16 ?>" id="wr_16" class="frm_input" size="10"></td>
</tr>
<tr>
<td>합계</td>
<td></td>
<td>
<button id="btn">계산</button>
<script>
$('#btn').click(function(){var sum =
parseInt($('#wr_9').val()) +
parseInt($('#wr_11').val()) +
parseInt($('#wr_13').val()) +
parseInt($('#wr_15').val());
$('#wr_4').val(sum);
});
</script>
<?php echo $wr_4 ?>
</td>
<td><?php echo number_format(($wr_8 * $wr_9)+($wr_10 * $wr_11)+($wr_12 * $wr_13)+($wr_14 * $wr_15)+$wr_16) ?></td>
</tr>
</table>