상품 리스트에서 선택한 가격이 주문서에 반영되게는 못하나요?
본문
item.form.skin.php
<div class="price_wr price">
<strong>월렌탈료</strong>
<span id="rental_price_display">
<?php
$initialPrice = min($it['it_36'], $it['it_39'], $it['it_48'], $it['it_60']);
echo display_price($initialPrice);
?>
</span>
<input type="hidden" id="it_price" value="<?php echo $initialPrice; ?>">
</div>
<?php } ?>
</div>
<div class="sit_ov_tbl">
<table>
<tbody>
<?php if ($it['it_id']) { ?>
<tr>
<th scope="row">모델명</th>
<td><?php echo $it['it_id']; ?></td>
</tr>
<?php } ?>
<?php if ($it['it_maker']) { ?>
<tr>
<th scope="row">소유권</th>
<td><?php echo $it['it_maker']; ?></td>
</tr>
<?php } ?>
<?php if ($it['it_origin']) { ?>
<tr>
<th scope="row">A/S 기간</th>
<td><?php echo $it['it_origin']; ?></td>
</tr>
<?php } ?>
<?php if ($it['it_brand']) { ?>
<tr>
<th scope="row">색상</th>
<td><?php echo $it['it_brand']; ?></td>
</tr>
<?php } ?>
<?php if ($it['it_model']) { ?>
<tr>
<th scope="row">제휴카드</th>
<td><?php echo $it['it_model']; ?></td>
</tr>
<?php } ?>
<?php if ($it['it_36'] || $it['it_39'] || $it['it_48'] || $it['it_60']) { ?>
<tr>
<th scope="row">렌탈기간 </th>
<td>
<input type="hidden" id="selected_price" name="selected_price" value="">
<?php
$checked = true;
$selectedRental = "";
if ($it['it_36']) { ?>
<input type="radio" id="rental_36" name="rental" value="<?php echo $it['it_36']; ?>" <?php echo $checked ? "checked" : ""; ?>>
<label for="rental_36">36개월</label>
<?php
if ($checked) {
$selectedRental = $it['it_36'];
$checked = false;
}
}
if ($it['it_39']) { ?>
<input type="radio" id="rental_39" name="rental" value="<?php echo $it['it_39']; ?>" <?php echo $checked ? "checked" : ""; ?>>
<label for="rental_39">39개월</label>
<?php
if ($checked) {
$selectedRental = $it['it_39'];
$checked = false;
}
}
if ($it['it_48']) { ?>
<input type="radio" id="rental_48" name="rental" value="<?php echo $it['it_48']; ?>" <?php echo $checked ? "checked" : ""; ?>>
<label for="rental_48">48개월</label>
<?php
if ($checked) {
$selectedRental = $it['it_48'];
$checked = false;
}
}
if ($it['it_60']) { ?>
<input type="radio" id="rental_60" name="rental" value="<?php echo $it['it_60']; ?>" <?php echo $checked ? "checked" : ""; ?>>
<label for="rental_60">60개월</label>
<?php
if ($checked) {
$selectedRental = $it['it_60'];
$checked = false;
}
}
?>
</td>
</tr>
<?php } ?>
<script>
function display_price(price) {
return new Intl.NumberFormat('ko-KR').format(price) + '원';
}
window.onload = function() {
const rentalRadios = Array.from(document.querySelectorAll('input[name="rental"]'));
const rentalPriceInput = document.querySelector('#it_price');
const rentalPriceDisplay = document.querySelector('#rental_price_display');
const selectedPriceInput = document.querySelector('#selected_price');
const availableRadios = rentalRadios.filter(radio => radio.value);
if (availableRadios.length > 0) {
availableRadios[0].checked = true;
rentalPriceInput.value = availableRadios[0].value;
rentalPriceDisplay.textContent = display_price(availableRadios[0].value);
selectedPriceInput.value = availableRadios[0].value;
}
rentalRadios.forEach(radio => {
radio.addEventListener('change', function() {
rentalPriceInput.value = this.value;
rentalPriceDisplay.textContent = display_price(this.value);
selectedPriceInput.value = this.value;
});
});
}
</script>
위 부분에서 선택한 라디오박스의 데이터값을 주문서로 넘기고 싶은데 어디를 건들여야될지도 모르겠네요 ㅠㅠ
실마리라도 찾고싶습니다 부탁드릴게요!!!!!!
!-->답변 2
최종적으로 이 값이 선택된 가격인것 같습니다.
selectedPriceInput.value = this.value;
var radio_price = selectedPriceInput.value = this.value;
이 radio_price 값을 장바구니로 넘길 때 아래와 가티 넘겨 주면 될 것입니다.
XXXXX.action = '....update.php?radioprice='+radio_price;
의뢰 하시는 것을 추천 합니다
이유는 저페이지에서 만 할게 아니라
.DB 에 저장을 해서 관리자 페이지 및 제품 주문의 마이페이에서도
확인 을 해야하니까요
그냥 저페이지에서 자바스크립트만 해서 활문제가 아니라 생각 됩니다
답변을 작성하시기 전에 로그인 해주세요.