Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
<pre>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();
  }
}

$('#datepicker').datepicker({
  minDate: 0,
  dateFormat: "dd-mm-yy"
});

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

  return adultPrice;
}

function updateTotal() {
  const total = calculateTotal();
  console.log(total);
  document.querySelector('#amount').value = total;

  
}
updateTotal();



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

javascript

What I have tried:

for (let i = adultprice ; adults < 4; i++)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900