Show the total based on select menu
I have this html below where the user can select how many "registrations" wants for each registration type. Each registration type has a price associated, so if the price of registration type "general" is "10€" and the price of the registration type "plus" is "5$" and the user selects just one of each registration type the total is 15$.
But if the user selects one of the registration type "general" and two of the registration type "plus" the total is 20$.
Do you know how to properly show the total in the <span> with class ".
total" based on user select menu selection
?
- <div class="card">
- <div class="card-header d-flex justify-content-between">
- <span class="w-100">Registration Type</span>
- <span class="w-50">Quantity</span>
- <span class="w-50">Price</span>
- </div>
- <div class="card_body">
- <ul class="list-group list-group-flush">
- <li class="list-group-item d-flex align-items-center justify-content-between">
- <div>
- <span>General</span>
- </div>
- <form>
- <select>
- <option >1</option>
- <option >2</option>
- <option >3</option>
- </select>
- </form>
- <span>X 10€</span>
- </li>
- <li class="list-group-item d-flex align-items-center justify-content-between">
- <div>
- <span>Plus</span>
- </div>
- <form>
- <select>
- <option >1</option>
- <option >2</option>
- <option >3</option>
- </select>
- </form>
- <span>X 5€</span>
- </li>
- <li class="list-group-item d-flex align-items-center justify-content-between">
- <div>
- <span>TOTAL</span>
- </div>
- <span class="total">10.00€</span>
- </li>
- </ul>
- </div>
- <div class="card-footer">
- <a href="">Next</a>
- </div>
- </div>
jQuery:
- $("#general, #plus").change(function () {
- var general = $("#general").val();
- var plus = $("#plus").val();
- var total = general + plus;
- $(".total").text(total).fadeIn();
- });