Hey ich brauche verzweifelte Hilfe hier, ich bin super neu zu jquery und ich habe diese Aufgabe, die in wie ... 12 Stunden oder so fällig ist?ERNSTE HILFE: Jquery Quiz Punktzahl
Ich habe 5 Stunden damit verbracht, dies zu versuchen, indem ich mehrere verschiedene Codesätze durchgegangen bin, aber ich verstehe es nicht! Wie auch immer, vielleicht kannst du mir helfen?
Was ich will, ist eine Punktzahl auf einer anderen HTML-Seite, aber die Punktzahl muss alles mit Jquery getan werden. Das Quiz erfolgt in HTML.
Das ist mein HTML für das Quiz:
<DOCTYPE! html>
<head>
<title> The Boy In the Striped Pajamas by John Boyne </title>
<link rel="stylesheet" type= "text/css" href="formstylesheet.css">
<link rel="stylesheet" type= "text/css" href="stylesheet.css">
<script src="jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="script.js"></script>
<!--- fontstyles --->
<link href='https://fonts.googleapis.com/css?family=Fredericka+the+Great' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Slabo+27px' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato:400,400italic' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="title">
<h1> The Boy in The Striped Pajamas</h1>
<h2> By John Boyne </h2>
</div>
<nav>
<ul>
<li><a href="index.html"><strong>Home</a></li>
<li><a href="author.html">About The Author</a> </li>
<li><a href="history.html">WW2 History</strong></a> </li>
<li><a href="quiz.html"><strong>Quiz!</strong></a> </li>
</ul>
</nav>
<div class="content">
<form name="myForm" action="answers.html" onsubmit="return validateForm()" method="post">
<h4>Let's do a Quiz!</h4>
<p> Make sure you have read both the history and story content first before answering!
<h6 id="q1"> Who were the two boy characters in the story?</h6>
<input type="radio" name="choices" value="0" id="1.0">Bruno & Schmuel<br>
<input type="radio" name="choices" value="1" id="1.1">Bruno & Schmel<br>
<input type="radio" name="choices" value="2" id="1.2"> Schmuell & Runo
<h6 id="q2"> Who is the author of <em>The Boy in The Striped Pajamas</em>?</h6>
<input type="radio" name="choices" value="0" id="2.0">Cassandra Clare<br>
<input type="radio" name="choices"" value="1" id="2.1">William Shakespeare<br>
<input type="radio" name="choices" value="2" id="2.2">John Boyne
<h6 id="q3"> What is <em>The Boy in The Striped Pajamas</em> about?</h6>
<input type="radio" name="choices" value="0" id="3.0">The First World War<br>
<input type="radio" name="choices" value="1" id="3.1">The Vietnam War<br>
<input type="radio" name="choices"" value="2" id="3.2">The Second World War
<h6 id="q4"> Who was the Chancellor of Germany during the Second World War?</h6>
<input type="radio" name="choices" value="0" id="4.0">Adolf Hitler<br>
<input type="radio" name="choices" value="1" id="4.1">Abraham Lincoln<br>
<input type="radio" name="choices" value="2" id="4.2"> Vladimir Putin
<h6 id="q5"> What time period was the Second World War?</h6>
<input type="radio" name="choices" value="0" id="5.0">1939-1944<br>
<input type="radio" name="choices" value="1" id="5.1">1941-1950<br>
<input type="radio" name="choices" value="2" id="5.2"> 1939-1945
<br>
<input type="submit" name="Submit" class="submit">
<input type="reset" name="Reset" class="reset">
</form>
</div>
</body>
<footer>
<ul>
<li><a href="index.html"><strong>Home</a></li>
<li><a href="author.html">About The Author</a> </li>
<li><a href="history.html">WW2 History</strong></a> </li>
<li><a href="quiz.html"><strong>Quiz!</strong></a> </li>
</ul>
</footer>
html für die Antworten:
<head>
<title> The Boy In the Striped Pajamas by John Boyne </title>
<link rel="stylesheet" type= "text/css" href="stylesheet.css">
<script src="jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="script.js"></script>
<!--- fontstyles --->
<link href='https://fonts.googleapis.com/css?family=Fredericka+the+Great' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Slabo+27px' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato:400,400italic' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="title">
<h1> The Boy in The Striped Pajamas</h1>
<h2> By John Boyne </h2>
</div>
<nav>
<ul>
<li><a href="index.html"><strong>Home</a></li>
<li><a href="author.html">About The Author</a> </li>
<li><a href="history.html">WW2 History</strong></a> </li>
<li><a href="quiz.html"><strong>Quiz!</strong></a> </li>
</ul>
</nav>
<div class="content">
<h4>Your Score:</h4>
<!--- have jquery insert score here --->
</div>
</body>
<footer>
<ul>
<li><a href="index.html"><strong>Home</a></li>
<li><a href="author.html">About The Author</a> </li>
<li><a href="history.html">WW2 History</strong></a> </li>
<li><a href="quiz.html"><strong>Quiz!</strong></a> </li>
</ul>
</footer>
Und schließlich meine Javascript-Datei:
// quiz - please dont judge!!
var score = 0;
function submit() {
var q1answer = $('#1.0');
var q2answer = $('#2.2');
var q3answer = $('#3.2');
var q4answer = $('#4.0');
var q5answer = $('#5.2');
function checkanswers() {
if (q1answer.checked === true) {
score ++;
}
else {
score;
} // question 2
if (q2answer.checked === true) {
score ++;
}
else {
score;
} //question 3
if (q3answer.checked === true) {
score ++;
}
else {
score;
}//question 4
if (q4answer.checked === true) {
score ++;
}
else {
score;
}//question 5
if (q5answer.checked === true) {
score ++;
}
else {
score;
}
function display() {
score.show();
answers.html("You Scored: " + score + "/5");
}
} }
Denken Sie, das Problem ist die Formatierung ist oder? Ich habe Javascript nicht viel gemacht, also verstehe ich kaum, was vor sich geht. Aber der Code, den ich oben geschrieben habe, verstehe ich, daher habe ich es geschrieben.
Es würde wirklich helfen!
Hallo Gabrielle! Willkommen bei StackOverflow. Können Sie bitte Ihre Codes auf das Problem eingrenzen, das Sie haben? Auch, was genau funktioniert nicht mit den oben genannten Codes, die Sie bisher ausprobiert haben? –
Schauen Sie sich die Farbcodierung Ihrer Frage an. Sie können feststellen, dass einige Anführungszeichen nicht übereinstimmen. Desweiteren denke ich, dass die Idee darin besteht, das Formular nicht zu POST zu schicken, sondern eine javascript/jquery Funktion zu verwenden, um das Ergebnis abzufangen und zu verarbeiten, ohne die Seite zu verlassen. – RST
@AndrewLyndem Danke, Das Hauptproblem, das ich habe, versucht, den Punktestand auf der Seite zu veröffentlichen. Wie mache ich das genau? Und, auch im Formular-Tag für das "action" -Attribut, was wäre ein guter Ort, um es zu senden, wenn es auf eine neue Seite gesendet wird, ist das keine gute Idee? –