I’m creating an HTML form and want to achieve the following with JS, please provide the code i should use.
Show total number of checkboxes user has selected.
Add values of all the checked checkboxes and show them as total.
Add a restriction the user must select at least 2 checkboxes
Here is my code.
<input class="iput" type="checkbox" name="E33" value="4500" />
<input class="iput" type="checkbox" name="E34" value="3000" />
<input class="iput" type="checkbox" name="E36" value="6000" />
<p>Total number of items selected = </p>
<p>Your Total is = </p>
Also code should not be dependent on the number of checkboxes, i mean to say that if i create new checkboxes i should not have to change the JS code too. The JS code should check all checkboxes on the page automatically even if there are 50 checkboxes.