How could I make it so if a user clicks the radio button with the data-price of 5.99 then the price will show up in the total box but if the user clicks the "no charge" radio button then nothing will show up
var radio = document.querySelector("input[name=deliveryType]");
for (var i = 0; i < radio.length; i++) {
  if (radio.checked) {
    l_totalPrice += parseFloat(radio.dataset.price);
  }
}
total.value = l_totalPrice;<section id="collection">
  <h2>Collection method</h2>
  <p>Please select whether you want your chosen event ticket(s) to be delivered to your home address (a charge applies for this) or whether you want to collect them yourself.</p>
  <p>
    Home address - £5.99 <input type="radio" name="deliveryType" value="home" data-price="5.99" checked>  |   Collect from ticket office - no charge <input type="radio" name="deliveryType" value="ticketOffice" data-price="0">
  </p>
</section>
<section id="checkCost">
  <h2>Total cost</h2>
  Total <input type="text" name="total" size="10" readonly>
</section> 
     
    