Skip to content

Instantly share code, notes, and snippets.

@YasuoFromDeadScream
Created May 24, 2021 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YasuoFromDeadScream/d97ca3972c3f04d9746256becf116902 to your computer and use it in GitHub Desktop.
Save YasuoFromDeadScream/d97ca3972c3f04d9746256becf116902 to your computer and use it in GitHub Desktop.
<script language="javascript" type="text/javascript">
var Choices = [];
// ①問題となる文字列を設定
const mondai = "1 + 1 = ??";
// ②正解となる文字列を設定
const seikai = "2";
// ③選択肢を増やす、7行目を例に行をコピーして張り付ける
Choices.push("2");
Choices.push("4");
document.write(" Quiz"),document.write(" <h5>"+mondai+"</h5>");for(let e=0;e<Choices.length;e++)document.write(" <div>"),document.write('\t <input type="radio" name="quizRadio" onchange="checkAnswer()" value="'+Choices[e]+'" >'),document.write("\t <label id="+e+' for="radio">'+Choices[e]+"</label>"),document.write("\t</div>");function checkAnswer(){var e=document.getElementsByName("quizRadio");for(let t=0;t<e.length;t++)if(e[t].checked&&e[t].value==seikai){document.getElementById(t);alert("正解")}}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment