-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcheckbox.html
More file actions
27 lines (27 loc) · 976 Bytes
/
Copy pathcheckbox.html
File metadata and controls
27 lines (27 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<html>
<head>
<script>
function handleCheckbox(){
let checkboxField=document.forms[0].additionals;
console.log(checkboxField, typeof(checkboxField));
for(let i=0; i< checkboxField.length;i++){
if(checkboxField[i].checked){
console.log("The selected option was:", checkboxField[i].value);
}
}
}
</script>
</head>
<body>
<h1>Multiple selector using checkbox</h1>
<form>
<input type="checkbox" name="additionals" value="cheese" /> Cheese
<br/>
<input type="checkbox" name="additionals" value="bacon" /> Bacon
<br/>
<input type="checkbox" name="additionals" value="tomate" /> Tomato
<br/>
<input type="button" value="Handle checkbox" onclick="handleCheckbox()" />
</form>
</body>
</html>