-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckbox.html
More file actions
28 lines (26 loc) · 966 Bytes
/
checkbox.html
File metadata and controls
28 lines (26 loc) · 966 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
28
<!DOCTYPE html>
<html>
<head>
<title>My Form with Checkboxes</title>
</head>
<body>
<div align="center">
<br>
Select the fruit(s) of your choice<br/>
<input type="checkbox" name="option1" value="mango" onchange="change(this)"> Mango<br/>
<input type="checkbox" name="option2" value="apple" onchange="change(this)"> Apple<br/>
<input type="checkbox" name="option3" value="guava" onchange="change(this)"> Guava<br/>
<p id="desc"></p>
</div>
<script>
function change(selectedCheckbox) {
var selectedValue = selectedCheckbox.value;
if (selectedCheckbox.checked) {
document.getElementById("desc").innerHTML = "You selected: " + selectedValue;
} else {
document.getElementById("desc").innerHTML = "You deselected: " + selectedValue;
}
}
</script>
</body>
</html>