I'm setting up a group of checkboxes that have values of different levels. Multiple levels can be selected and then submitted using the submit button. The submit button should then pass those values as parameters to a function in the typescript class.
I would like to pass the values as parameters. For example, if only level one and level two are selected the method and parameters would look like this:
levelSave(value1,value2)
Thanks in advance!
HTML
<div class="form-group">
<li><input type="checkbox" id="level1" value="1" required><label for="level1"></label> Level 1 </li>
<li><input type="checkbox" id="level2" value="2" required><label for="level2"></label> Level 2 </li>
<li><input type="checkbox" id="level3" value="3" required><label for="level3"></label> Level 3 </li>
</div>
</ul>
<button type="button" class="green-btn pop-up-btn" (click)="levelSave()" id="LevelPopupSubmit">Submit</button>
TypeScript
levels = [];
//value3 if level 3 was selected
levelSave(value1,value2){
levels.push(value1);
levels.push(value2);
}