Created
January 30, 2019 12:55
-
-
Save gmelodie/bd1a99d2c608d2489c8831e4b366ffd2 to your computer and use it in GitHub Desktop.
Version 2 of tic-tac-toe, fixing hiding problems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<script type="text/javascript"> | |
function getSelectedButton(form, name) { | |
let radios = form.elements[name]; | |
for (button in radios) { | |
if (radios[button].checked) { | |
return radios[button]; | |
} | |
} | |
} | |
function computePlay() { | |
let selected = getSelectedButton(document.getElementById('board'), 'play'); | |
selected.style.display = 'none'; | |
} | |
</script> | |
<h1> Tic-tac-toe </h1> | |
<form id='board'> | |
<input type="radio" name="play" onclick="computePlay()" id="11"> | |
<input type="radio" name="play" onclick="computePlay()" id="12"> | |
<input type="radio" name="play" onclick="computePlay()" id="13"> | |
<br> | |
<input type="radio" name="play" onclick="computePlay()" id="21"> | |
<input type="radio" name="play" onclick="computePlay()" id="22"> | |
<input type="radio" name="play" onclick="computePlay()" id="23"> | |
<br> | |
<input type="radio" name="play" onclick="computePlay()" id="31"> | |
<input type="radio" name="play" onclick="computePlay()" id="32"> | |
<input type="radio" name="play" onclick="computePlay()" id="33"> | |
<br> | |
</form> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment