<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Check All Example</title>
</head>
<body>
<select id="selectOption">
<option value="default">Select an option</option>
<option value="completed">Completed</option>
</select>
<div>
<input type="checkbox" id="check1"> Item 1<br>
<input type="checkbox" id="check2"> Item 2<br>
<input type="checkbox" id="check3"> Item 3<br>
</div>
<script>
document.getElementById('selectOption').addEventListener('change', function() {
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
if (this.value === 'completed') {
checkboxes.forEach(checkbox => checkbox.checked = true);
}
});
</script>
</body>
</html>
just use this code for example. easy, simple and yet understandable