mercredi 10 mars 2021

How to sum all values of checked checkboxes using alpinejs

Hi have a custom form where I want to sum the values of all checked checkboxes using alpinejs.

Something like this:

<div x-data="price : 0">
  <input @click="price = 200"  type="checkbox" name="event1" value="200">
  <input @click="price = 299" type="checkbox" name="event2" value="299">
  <p x-text="total"></p>
</div>



Aucun commentaire:

Enregistrer un commentaire