Now I want to use "check/unchecked checkbox" as "IF condition statement".
Example: I want to make a chord analyzer based on the note(s) you hit. When you check a note (or some notes) on checkbox, then press the button under those checkboxes, the paragraph element should tell you about what chord you hit. But there's error on my writing at if ("error")
statement. How to fix it?
Here's my code:
<!doctype html>
<html>
<head>
<script>
function fungsi() {
var c = document.getElementById("C").checked;
var e = document.getElementById("E").checked;
var f = document.getElementById("F").checked;
var g = document.getElementById("G").checked;
if (c.checked = true &&
e.checked = true &&
g.checked = true &&
f.checked = false) {
document.getElementById("chord").innerHTML = "C Chord";
} else if (c.checked = true &&
f.checked = true &&
g.checked = false &&
e.checked = false) {
document.getElementById("chord").innerHTML = "F Chord";
} else {
alert("Under Development!");
}
}
</script>
</head>
<body>
<form>
Note(s) That You Hit:<br>
<input type=checkbox id="C">C<br>
<input type=checkbox id="E">E<br>
<input type=checkbox id="F">F<br>
<input type=checkbox id="G">G
</form>
<button type=button onclick="fungsi()">The Chord Is</button>
<p id="chord"></p>
</body>
</html>