-
Notifications
You must be signed in to change notification settings - Fork 0
/
ch9onchanheatrnotificatchecbx.html
43 lines (40 loc) · 1.06 KB
/
ch9onchanheatrnotificatchecbx.html
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<title>Checkbox onchange Example</title>
</head>
<body>
<h2>Checkbox onchange Example</h2>
<input type="checkbox" id="myCheckbox" onchange="handleChange()">
<label for="myCheckbox">Click me!</label>
<script>
function handleChange() {
var checkbox = document.getElementById("myCheckbox");
if (checkbox.checked) {
alert("Checkbox is checked!");
} else {
alert("Checkbox is unchecked!");
}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Radio Button Example</title>
</head>
<body>
<form>
<input type="radio" name="color" value="red" onchange="displayColor()"> Red<br>
<input type="radio" name="color" value="green" onchange="displayColor()"> Green<br>
<input type="radio" name="color" value="blue" onchange="displayColor()"> Blue<br>
</form>
<script>
function displayColor() {
var selectedColor = document.querySelector('input[name="color"]:checked').value;
alert("You selected " + selectedColor + " color.");
}
</script>
</body>
</html>