How do include javascript to item checkbox so that the selected box calculates the price value automatucally?

  class, flexbox, forms, html, javascript

Display four or more items to purchase along with their corresponding purchase price (use check boxes to allow selection of the items you wish to purchase). Give the checkboxes the name item_0, item_1, etc.
Include a Total field which automatically totals your purchases as each item is checked/unchecked or the specified quantity changes. Give this field the name total.

I need some help with this.

Here is the code of the simplest I have been able to do so far.

<h3> Cart </h3>
<input type = "checkbox" id = "item_0" name ="item_0" value = "Malt">
<label> Beta Malt </label>
<input type = "checkbox" id = "item_1" name ="item_1" value = "bread">
<label> A1 Bread </label>
<input type = "checkbox" id = "item_0" name ="item_2" value = "noodles">
<label> Indomie </label>
<input type = "checkbox" id = "item_0" name ="item_3" value = "milk">
<label> Cowbell </label>

Source: Ask Javascript Questions

LEAVE A COMMENT