I have 3 checkboxes in my website, and a button to submit the answers to the questions. How do I make the button disabled by default, and only after the person has checked the 3 checkboxes it would we undisabled? I tried implementing an IF statement, but even after a person has checked at least 1 answer on each checkbox it would still be disabled. Here is a part of my code:
Why is my IF statement not working? thanks in advance!
const colorblind = document.getElementById("colorblindoptions");
const soundyes = document.getElementById("soundyes");
const soundno = document.getElementById("soundno");
const biglettersyes = document.getElementById("biglettersyes");
const biglettersno = document.getElementById("biglettersno");
const explanationyes = document.getElementById("explanationyes");
const explanationno = document.getElementById("explanationno");
const submit = document.getElementById("submit");
const table = document.getElementById("settingstable");
const buttondiv = document.getElementById("buttondiv");
const everythingdiv = document.getElementById("everything");
if ((soundyes.checked == true || soundno.checked == true) && (biglettersyes.checked == true || biglettersno.checked == true) && (explanationyes.checked == true || explanationno.checked == true)) {
submit.disabled = false;
}
else {
submit.disabled = true;
}
<table id = "settingstable">
<tr>
<th>
Settings
</th>
<th>
Yes
</th>
<th>
No
</th>
</tr>
<tr>
<td>
<select name = "colorblind" id = "colorblindoptions">
<option value = "nocolorblind"> I'm not colorblind </option>
<option value = "achromatopsia"> Achromatopsia </option>
<option value = "monoachromatopsia"> Monoachromatopsia </option>
<optgroup label = "Dichromacy">
<option value = "deuteranopia"> Deuteranopia </option>
<option value = "tritanopia"> Tritanopia </option>
</optgroup>
</select>
</td>
</tr>
<tr>
<td>
<p class = "text">
Would you like voice-sound?
</p>
</td>
<td>
<input type = "radio" id = "soundyes" name = "sound" value = "soundyes">
</td>
<td>
<input type = "radio" id = "soundno" name = "sound" value = "soundno">
</td>
</tr>
<tr>
<td>
<p class = "text">
Would you like big letters?
</p>
</td>
<td>
<input type = "radio" id = "biglettersyes" name = "bigletters" value = "biglettersyes">
</td>
<td>
<input type = "radio" id = "biglettersno" name = "bigletters" value = "biglettersno">
</td>
</tr>
<tr>
<td>
<p class = "text">
Would you like explanations on pictures?
</p>
</td>
<td>
<input type = "radio" id = "explanationyes" name = "explanation" value = "explanationyes">
</td>
<td>
<input type = "radio" id = "explanationno" name = "explanation" value = "explanationno">
</td>
</tr>
</table>
<div id = "buttondiv">
<button id = "submit"> Submit </button>
</div>