hi i want to apply loop for on this equation const adultPrice = privateAdultPrice + (adults -1) * privateAdultPrice2 and setting the limit on adults that after every 4 it repeats
updateTotal();
function increaseCount(e, el) {
var input = el.previousElementSibling;
var value = parseInt(input.value, 10);
value = isNaN(value) ? 0 : value;
value++;
input.value = value;
updateTotal();
}
function decreaseCount(e, el) {
var input = el.nextElementSibling;
var value = parseInt(input.value, 10);
if (value > 1) {
value = isNaN(value) ? 0 : value;
value--;
input.value = value;
updateTotal();
}
}
function decreaseCount2(e, el) {
var input = el.nextElementSibling;
var value = parseInt(input.value, 10);
if (value > 0) {
value = isNaN(value) ? 0 : value;
value--;
input.value = value;
updateTotal();
}
}
function calculateTotal() {
const privateAdultPrice = 500;
const privateAdultPrice2 = 125;
const adults = +document.querySelector('#adults').value;
const isPrivate = document.getElementById('private').checked;
const adultPrice = privateAdultPrice + (adults -1) * privateAdultPrice2
for (let i = adultPrice ; adults < 5; ++i)
return i ;
}
function updateTotal() {
const total = calculateTotal();
console.log(total);
document.querySelector('#amount').value = total;
}
updateTotal();
<div class="total-price"><label class="total"> Total USD:</label><input type="number" id="amount"class="total" readonly></label> >
<div class="counter1">
<div class='down' onclick='decreaseCount(event, this)'>-</div>
<input id="adults" type='text' value='1' readonly>
<div class='up' onclick='increaseCount(event, this)'>+</div>
</div>
<div style="display: flex; width: 100%">
<input type="radio" name="occupancy" id="private" autocomplete="off" checked="checked" onclick="updateTotal()">
<label for="private">Private</label>
<input type="radio" name="occupancy" id="shared" value="Shared Evening Safari" autocomplete="off" onclick="updateTotal()">
<label for="shared">Shared</label>
hi i want to apply loop for on this equation const adultPrice = privateAdultPrice + (adults -1) * privateAdultPrice2 and setting the limit on adults that after every 4 it repeats
is it possible or i am in in illusion which is not possible at-all please help me on this one
for (let i = adultPrice ; adults < 5; ++i)
this is the problem i guess its not repeating
edited ------------------------------------------- formula should be applied depending on checkbox let say a person select shared check box then price should change qty 1 = 125 and 125 x qty if private selected then your formula should be applied