This is my Code for my Quiz. I tried to change it somehow but it still doesnt let me choose more than one option. Do i need an extra Code or do i have to change the whole thing? Also if anyone can see any errors, please say so. Thank You in Advance :)
<html>
<head>
<title>Knowledge Test</title>
<link rel="stylesheet" href="style folder/styles.css" type="text/css" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
<script type="text/javascript">
var numQuest=8
var ie=document.all
function showAnswer(el,ans){
ie? ie[el].innerHTML='The answer is: '+ ans : document.getElementById(el).innerHTML='The answer is: '+ ans
}
function addup() {
var q, right, statement, total=0
questions=new Array();
for (i = 0; i < numQuest; i++)
questions[i]=0
if (document.forms.quiz.q1['right1']){
for (i = 0; i < numQuest; i++){
q="q"+(i+1)
right="right"+(i+1)
if (document.forms.quiz[q][right].checked)
questions[i]=1
}
}
else if (document.getElementById){
for (i = 0; i < numQuest; i++){
right="right"+(i+1)
if (document.getElementById(right).checked)
questions[i]=1
}
}
else
return;
for (i = 0; i < numQuest; i++)
total += questions[i]
/*///////////Set score /////////////*/
statement='You scored '+ total +' out of '+ numQuest +' correct, '+ Math.round(total/numQuest*100) +'%'
ie? ie.results.innerHTML=statement : document.getElementById('results').innerHTML=statement
}
function clearR(){
ie? ie.results.innerHTML='' : document.getElementById('results').innerHTML=''
for (i = 0; i < numQuest; i++)
ie? ie["ans"+(i+1)].innerHTML='' : document.getElementById("ans"+(i+1)).innerHTML=''
}
</script>
</head>
<body>
<div id="container">
<header>
<div class="width">
<h1>Quiz</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="accessibility.html">Accessibility</a></li>
<li><a href="usability.html">Usability</a></li>
<li><a href="additional information.html">Additional Information</a></li>
<li><a href="how i built this website.html">How I built this Website</a></li>
<li><a href="Quiz.html">Quiz</a></li>
</ul>
</nav>
</div>
</header>
<div id="body" class="width">
<center><h1>Test your Knowledge</h1></center>
<hr>
<form name="quiz">
Question 1:<br>
Which HTML attribute is used to define an inline style sheet?<br>
<input id="w1a" type="radio" unchecked name="q1"><label for="w1a">class</label><br>
<input id="right1" type="radio" unchecked name="q1"><label for="right1">style</label><br>
<input id="w1b" type="radio" unchecked name="q1"><label for="w1b">in-style</label><br>
<input id="w1c" type="radio" unchecked name="q1"><label for="w1c">font</label><br>
<input class="chkans" type="button" value="Check Answer" onclick="showAnswer('ans1','style')"> <span id="ans1" class="chkans"></span>
<br> <br>
Question 2:<br>
What is the correct CSS syntax for making all the <"p"> elements bold?<br>
<input id="w2a" type="radio" unchecked name="q2"><label for="w2a">p style="text-size:bold"</label><br>
<input id="w2b" type="radio" unchecked name="q2"><label for="w2b">p {text-size:bold}</label><br>
<input id="right2" type="radio" unchecked name="q2"><label for="right2">p{font-weight:bold}</label><br>
<input id="w2c" type="radio" unchecked name="q2"><label for="w2c">p style="font-size:bold"</label><br>
<input class="chkans" type="button" value="Check Answer" onclick="showAnswer('ans2','p{font-weight:bold}')"> <span id="ans2" class="chkans"></span>
<br> <br>
Question 3:<br>
What does HTML stand for?<br>
<input id="w3a" type="radio" unchecked name="q3"><label for="w3a">Hyperlinks and Text Markup Language</label><br>
<input id="w3b" type="radio" unchecked name="q3"><label for="w3b">Home Tool Markup Language</label><br>
<input id="right3" type="radio" unchecked name="q3"><label for="right3">Hyper Text Markup Laguage</label><br>
<input id="w3c" type="radio" unchecked name="q3"><label for="w3c">High Technic Markup Language</label><br>
<input class="chkans" type="button" value="Check Answer" onclick="showAnswer('ans3','Hyper Text Markup Laguage')"> <span id="ans3" class="chkans"></span>
<br> <br>
Question 4:<br>
What does CSS stand for?<br>
<input id="right4" type="radio" unchecked name="q4"><label for="right4">Cascading Style Sheets</label><br>
<input id="w4a" type="radio" unchecked name="q4"><label for="w4a">Creative Style Sheets</label><br>
<input id="w4b" type="radio" unchecked name="q4"><label for="w4b">Computer Style Sheets</label><br>
<input id="w4c" type="radio" unchecked name="q4"><label for="w4c">Colorful Style Sheets</label><br>
<input class="chkans" type="button" value="Check Answer" onclick="showAnswer('ans4','Cascading Style Sheets')"> <span id="ans4" class="chkans"></span>
<br> <br>
Question 5:<br>
Choose the right text color for a Website with a white background.<br>
<input id="right5" type="radio" unchecked name="q5"><label for="right5">black</label><br>
<input id="w5a" type="radio" unchecked name="q5"><label for="w5a">orange</label><br>
<input id="w5b" type="radio" unchecked name="q5"><label for="w5b">red</label><br>
<input id="w5c" type="radio" unchecked name="q5"><label for="w5c">yellow</label><br>
<input class="chkans" type="button" value="Check Answer" onclick="showAnswer('ans5','black')"> <span id="ans5" class="chkans"></span>
<br> <br>
Question 6:<br>
Where in an HTML document is the correct place to refer to an external style sheet?<br>
<input id="w6a" type="radio" unchecked name="q6"><label for="w6a">In the <"head"> section</label><br>
<input id="w6b" type="radio" unchecked name="q6"><label for="w6b">At the end of the document</label><br>
<input id="right6" type="radio" unchecked name="q6"><label for="right6">At the top of the document</label><br>
<input id="w6c" type="radio" unchecked name="q6"><label for="w6c">In the <"body"> section</label><br>
<input class="chkans" type="button" value="Check Answer" onclick="showAnswer('ans6','black')"> <span id="ans6" class="chkans"></span>
<br> <br>
Question 7:<br>
Which property is used to change the background color?<br>
<input id="w7a" type="radio" unchecked name="q7"><label for="w7a">color</label><br>
<input id="right7" type="radio" unchecked name="q7"><label for="right7">background-color</label><br>
<input id="w7b" type="radio" unchecked name="q7"><label for="w7b">bgcolor</label><br>
<input id="w7c" type="radio" unchecked name="q7"><label for="w7c">bgc</label><br>
<input class="chkans" type="button" value="Check Answer" onclick="showAnswer('ans7','black')"> <span id="ans7" class="chkans"></span>
<br> <br>
Question 8:<br>
On a web page, how and where should be the logo/brand name?(choose 2)<br>
<input id="right8" type="radio" unchecked name="q8"><label for="right8">easy</label><br>
<input id="right8" type="radio" unchecked name="q8"><label for="right8">upper-left corner of the screen</label><br>
<input id="w8a" type="radio" unchecked name="q8"><label for="w8a">in the middle of the screen</label><br>
<input id="w8b" type="radio" unchecked name="q8"><label for="w8b">hard</label><br>
<input class="chkans" type="button" value="Check Answer" onclick="showAnswer('ans8','easy','upper-left corner of the screen')"> <span id="ans8" class="chkans"></span>
<br> <br>
<!--End of Questions-->
<hr><br>
<input type="button" value="See Score" onclick="addup()"> <span id="results"></span><br> <br>
<input type="button" value="Start Again" onclick="reset();clearR()">
</form>
</div>
</div>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire