Post by Mike on Oct 9, 2020 8:50:21 GMT -8
I have a quiz code made with html, and js, on a custom page. I would like to use a button to cause an accordion effect.
I have the code below:
code]<head>
<title>Quiz Questions And Answers</title>
</head>
<body>
<button onclick="myFunction()">Quiz</button>
<script>
function myFunction() {
var x = document.getElementByname("quiz");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
</script>
<center><h1>Quiz 1</h1></center>
<p>
<form name="quiz">
<p>
<b>Question 1. Hint:The book of
Genesis
<br>Then the Lord God called to Adam and said to him, “_____________”<br></b>
<blockquote>
<input type="radio" name="q1" value="false">Come here Adam!<br>
<input type="radio" name="q1" value="true">Where are you?<br>
<input type="radio" name="q1" value="false">Adam, come here!<br>
</blockquote>
<p><b>
<hr>
Question 2. Hint:The book of Exodus
<br>Who said this:“I have surely seen the oppression of My people who are in Egypt"<br></b>
<blockquote>
<input type="radio" name="q2" value="false">Moses<br>
<input type="radio" name="q2" value="false">Isaac<br>
<input type="radio" name="q2" value="true">God<br>
</blockquote>
<p><b>
<hr>
Question 3. Hint:The book of Leviticus
<br>So they brought what _______ commanded before the tabernacle of meeting.<br>
And all the congregation drew near and stood before the ____.<b></b>
<blockquote>
<input type="radio" name="q3" value="true">Moses and Lord<br>
<input type="radio" name="q3" value="false">Lord and Moses<br>
<input type="radio" name="q3" value="false">Daniel and Lord<br>
</blockquote>
<p><b>
<hr>
Question 4. Hint:The book of Numbers
<br>Now the Lord spoke to Moses in the ______ of Sinai,<br>
in the _____ month of the second year after they had come out of the land of Egypt<br></b>
<blockquote>
<input type="radio" name="q4" value="false">Mountain and first<br>
<input type="radio" name="q4" value="false">sea and second<br>
<input type="radio" name="q4" value="true">wilderness and second<br>
</blockquote>
<p><b>
<hr>
Question 5. Hint:The book of Deuteronomy
<br> you shall not ____ down to them nor serve them. For I, the Lord your God, am a ______ God,<br></b>
<blockquote>
<input type="radio" name="q5" value="false">Kneel and proud<br>
<input type="radio" name="q5" value="true">Bow and jealous<br>
<input type="radio" name="q5" value="doesn't make">lie and honorable<br>
</blockquote>
<p><b>
<hr>
Question 6. Hint:The book of Joshua
<br>Who said this? “Cross over before the ark of the Lord your God into the midst of the Jordan,<br>
and each one of you take up a stone on his shoulder"<br></b>
<blockquote>
<input type="radio" name="q6" value="false">God<br>
<input type="radio" name="q6" value="true">Joshua<br>
<input type="radio" name="q6" value="false">Moses<br>
</blockquote>
<p><b>
Question 7. Hint:The book of Judges
<br>Who sang The Song of Deborah?<br></b>
<blockquote>
<input type="radio" name="q7" value="false">Cain and Able<br>
<input type="radio" name="q7" value="false">Moses and Joshua<br>
<input type="radio" name="q7" value="true">Deborah and Barak<br>
</blockquote>
<p><b>
<hr>
Question 8. Hint:The book of Ruth
<br>Who said this to Ruth? “You will listen, my daughter, will you not?"<br></b>
<blockquote>
<input type="radio" name="q8" value="false">Moses<br>
<input type="radio" name="q8" value="true">Boaz<br>
<input type="radio" name="q8" value="false">The Lord<br>
</blockquote>
<p><b>
<hr>
Question 9. Hint: 2 Samuel
<br>Who was the daughter of Saul?<br></b>
<blockquote>
<input type="radio" name="q9" value="false">Naomi<br>
<input type="radio" name="q9" value="false">Deborah<br>
<input type="radio" name="q9" value="true">Michal<br>
</blockquote>
<p><b>
<hr>
Question 10. 2 kings
<br>How many years did Jehoram serve as king of Israel? <br></b>
<blockquote>
<input type="radio" name="q10" value="true">12 years<br>
<input type="radio" name="q10" value="false">4 years<br>
<input type="radio" name="q10" value="false">10 years<br>
</blockquote>
<p><b>
<hr>
Question 11. Hint:Psalm
<br>How long, O you sons of ____,<br>
Will you turn my glory to shame?<br>
How long will you love worthlessness<br>
And seek ______? Selah<br></b>
<blockquote>
<input type="radio" name="q11" value="false">Abraham and water<br>
<input type="radio" name="q11" value="true">Men and falsehood<br>
<input type="radio" name="q11" value="false">Moses and Israel<br>
</blockquote>
<p><b>
<hr>
Question 12.
<br>In what book and verse can I find this?<br>
I said in my heart,<br>
“God shall judge the righteous and the wicked,<br>
For there is a time there for every purpose and for every work.”<br></b>
<blockquote>
<input type="radio" name="q12" value="false">Proverbs 3:17<br>
<input type="radio" name="q12" value="false">Psalm 3:17<br>
<input type="radio" name="q12" value="true">Ecclesiastes 3:17<br>
</blockquote>
<p><b>
<hr>
Question 13. Hint: Nehemiah 2
<br>Nehemiah asked a king to be sent to Judah to rebuild it.<br>
What was the name of the king?<br></b>
<blockquote>
<input type="radio" name="q13" value="true">Artaxerxes<br>
<input type="radio" name="q13" value="false">Herod<br>
<input type="radio" name="q13" value="false">Ceasar<br>
</blockquote>
<p><b>
<hr>
Question 14.
<br><br>In what book and verse can I find this?<br>
“Do not say, ‘A conspiracy,’<br>
Concerning all that this people call a conspiracy,<br>
Nor be afraid of their threats, nor be troubled."</b>
<blockquote>
<input type="radio" name="q14" value="true">Isaiah 8:12<br>
<input type="radio" name="q14" value="false">plays<br>
<input type="radio" name="q14" value="false">playing<br>
</blockquote>
<p><b>
<hr>
Question 15.
<br>The exam -------------------- two hours.<br></b>
<blockquote>
<input type="radio" name="q15" value="last">last<br>
<input type="radio" name="q15" value="lastes">lastes<br>
<input type="radio" name="q15" value="lasts">lasts<br>
</blockquote>
<p><b>
<input type="button"value="Grade Me"onClick="getScore(this.form);">
<input type="reset" value="Clear"><p>
Number of score out of 15 = <input type= text size 15 name= "mark">
Score in percentage = <input type=text size=15 name="percentage"><br>
</form>
<p>
<form method="post" name="Form" onsubmit="" action="">
</form>
</body>
<script>
var numQues = 15;
var numChoi = 3;
var answers = new Array(15);
answers[0] = "true";
answers[1] = "true";
answers[2] = "true";
answers[3] = "true";
answers[4] = "true";
answers[5] = "true";
answers[6] = "true";
answers[7] = "true";
answers[8] = "true";
answers[9] = "true";
answers[10] = "true";
answers[11] = "true";
answers[12] = "true";
answers[13] = "true";
answers[14] = "true";
function getScore(form) {
var score = 0;
var currElt;
var currSelection;
for (i=0; i<numQues; i++) {
currElt = i*numChoi;
answered=false;
for (j=0; j<numChoi; j++) {
currSelection = form.elements[currElt + j];
if (currSelection.checked) {
answered=true;
if (currSelection.value == answers) {
score++;
break;
}
}
}
if (answered ===false){alert("Do answer all the questions, Please") ;return false;}
}
var scoreper = Math.round(score/numQues*100);
form.percentage.value = scoreper + "%";
form.mark.value=score;
}
</script>
</html>[/code]
As you can see I have a button code at the top but still is not working.
Could somebody help me with this please?
I have the code below:
code]<head>
<title>Quiz Questions And Answers</title>
</head>
<body>
<button onclick="myFunction()">Quiz</button>
<script>
function myFunction() {
var x = document.getElementByname("quiz");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
</script>
<center><h1>Quiz 1</h1></center>
<p>
<form name="quiz">
<p>
<b>Question 1. Hint:The book of
Genesis
<br>Then the Lord God called to Adam and said to him, “_____________”<br></b>
<blockquote>
<input type="radio" name="q1" value="false">Come here Adam!<br>
<input type="radio" name="q1" value="true">Where are you?<br>
<input type="radio" name="q1" value="false">Adam, come here!<br>
</blockquote>
<p><b>
<hr>
Question 2. Hint:The book of Exodus
<br>Who said this:“I have surely seen the oppression of My people who are in Egypt"<br></b>
<blockquote>
<input type="radio" name="q2" value="false">Moses<br>
<input type="radio" name="q2" value="false">Isaac<br>
<input type="radio" name="q2" value="true">God<br>
</blockquote>
<p><b>
<hr>
Question 3. Hint:The book of Leviticus
<br>So they brought what _______ commanded before the tabernacle of meeting.<br>
And all the congregation drew near and stood before the ____.<b></b>
<blockquote>
<input type="radio" name="q3" value="true">Moses and Lord<br>
<input type="radio" name="q3" value="false">Lord and Moses<br>
<input type="radio" name="q3" value="false">Daniel and Lord<br>
</blockquote>
<p><b>
<hr>
Question 4. Hint:The book of Numbers
<br>Now the Lord spoke to Moses in the ______ of Sinai,<br>
in the _____ month of the second year after they had come out of the land of Egypt<br></b>
<blockquote>
<input type="radio" name="q4" value="false">Mountain and first<br>
<input type="radio" name="q4" value="false">sea and second<br>
<input type="radio" name="q4" value="true">wilderness and second<br>
</blockquote>
<p><b>
<hr>
Question 5. Hint:The book of Deuteronomy
<br> you shall not ____ down to them nor serve them. For I, the Lord your God, am a ______ God,<br></b>
<blockquote>
<input type="radio" name="q5" value="false">Kneel and proud<br>
<input type="radio" name="q5" value="true">Bow and jealous<br>
<input type="radio" name="q5" value="doesn't make">lie and honorable<br>
</blockquote>
<p><b>
<hr>
Question 6. Hint:The book of Joshua
<br>Who said this? “Cross over before the ark of the Lord your God into the midst of the Jordan,<br>
and each one of you take up a stone on his shoulder"<br></b>
<blockquote>
<input type="radio" name="q6" value="false">God<br>
<input type="radio" name="q6" value="true">Joshua<br>
<input type="radio" name="q6" value="false">Moses<br>
</blockquote>
<p><b>
Question 7. Hint:The book of Judges
<br>Who sang The Song of Deborah?<br></b>
<blockquote>
<input type="radio" name="q7" value="false">Cain and Able<br>
<input type="radio" name="q7" value="false">Moses and Joshua<br>
<input type="radio" name="q7" value="true">Deborah and Barak<br>
</blockquote>
<p><b>
<hr>
Question 8. Hint:The book of Ruth
<br>Who said this to Ruth? “You will listen, my daughter, will you not?"<br></b>
<blockquote>
<input type="radio" name="q8" value="false">Moses<br>
<input type="radio" name="q8" value="true">Boaz<br>
<input type="radio" name="q8" value="false">The Lord<br>
</blockquote>
<p><b>
<hr>
Question 9. Hint: 2 Samuel
<br>Who was the daughter of Saul?<br></b>
<blockquote>
<input type="radio" name="q9" value="false">Naomi<br>
<input type="radio" name="q9" value="false">Deborah<br>
<input type="radio" name="q9" value="true">Michal<br>
</blockquote>
<p><b>
<hr>
Question 10. 2 kings
<br>How many years did Jehoram serve as king of Israel? <br></b>
<blockquote>
<input type="radio" name="q10" value="true">12 years<br>
<input type="radio" name="q10" value="false">4 years<br>
<input type="radio" name="q10" value="false">10 years<br>
</blockquote>
<p><b>
<hr>
Question 11. Hint:Psalm
<br>How long, O you sons of ____,<br>
Will you turn my glory to shame?<br>
How long will you love worthlessness<br>
And seek ______? Selah<br></b>
<blockquote>
<input type="radio" name="q11" value="false">Abraham and water<br>
<input type="radio" name="q11" value="true">Men and falsehood<br>
<input type="radio" name="q11" value="false">Moses and Israel<br>
</blockquote>
<p><b>
<hr>
Question 12.
<br>In what book and verse can I find this?<br>
I said in my heart,<br>
“God shall judge the righteous and the wicked,<br>
For there is a time there for every purpose and for every work.”<br></b>
<blockquote>
<input type="radio" name="q12" value="false">Proverbs 3:17<br>
<input type="radio" name="q12" value="false">Psalm 3:17<br>
<input type="radio" name="q12" value="true">Ecclesiastes 3:17<br>
</blockquote>
<p><b>
<hr>
Question 13. Hint: Nehemiah 2
<br>Nehemiah asked a king to be sent to Judah to rebuild it.<br>
What was the name of the king?<br></b>
<blockquote>
<input type="radio" name="q13" value="true">Artaxerxes<br>
<input type="radio" name="q13" value="false">Herod<br>
<input type="radio" name="q13" value="false">Ceasar<br>
</blockquote>
<p><b>
<hr>
Question 14.
<br><br>In what book and verse can I find this?<br>
“Do not say, ‘A conspiracy,’<br>
Concerning all that this people call a conspiracy,<br>
Nor be afraid of their threats, nor be troubled."</b>
<blockquote>
<input type="radio" name="q14" value="true">Isaiah 8:12<br>
<input type="radio" name="q14" value="false">plays<br>
<input type="radio" name="q14" value="false">playing<br>
</blockquote>
<p><b>
<hr>
Question 15.
<br>The exam -------------------- two hours.<br></b>
<blockquote>
<input type="radio" name="q15" value="last">last<br>
<input type="radio" name="q15" value="lastes">lastes<br>
<input type="radio" name="q15" value="lasts">lasts<br>
</blockquote>
<p><b>
<input type="button"value="Grade Me"onClick="getScore(this.form);">
<input type="reset" value="Clear"><p>
Number of score out of 15 = <input type= text size 15 name= "mark">
Score in percentage = <input type=text size=15 name="percentage"><br>
</form>
<p>
<form method="post" name="Form" onsubmit="" action="">
</form>
</body>
<script>
var numQues = 15;
var numChoi = 3;
var answers = new Array(15);
answers[0] = "true";
answers[1] = "true";
answers[2] = "true";
answers[3] = "true";
answers[4] = "true";
answers[5] = "true";
answers[6] = "true";
answers[7] = "true";
answers[8] = "true";
answers[9] = "true";
answers[10] = "true";
answers[11] = "true";
answers[12] = "true";
answers[13] = "true";
answers[14] = "true";
function getScore(form) {
var score = 0;
var currElt;
var currSelection;
for (i=0; i<numQues; i++) {
currElt = i*numChoi;
answered=false;
for (j=0; j<numChoi; j++) {
currSelection = form.elements[currElt + j];
if (currSelection.checked) {
answered=true;
if (currSelection.value == answers) {
score++;
break;
}
}
}
if (answered ===false){alert("Do answer all the questions, Please") ;return false;}
}
var scoreper = Math.round(score/numQues*100);
form.percentage.value = scoreper + "%";
form.mark.value=score;
}
</script>
</html>[/code]
As you can see I have a button code at the top but still is not working.
Could somebody help me with this please?