Test Java

Fermé
titoumic1 Messages postés 1 Date d'inscription mercredi 10 décembre 2014 Statut Membre Dernière intervention 10 décembre 2014 - 10 déc. 2014 à 15:15
mr_demonicon Messages postés 828 Date d'inscription dimanche 20 juillet 2014 Statut Membre Dernière intervention 9 avril 2016 - 10 déc. 2014 à 16:51
Bonjour, je dois creer un mini test sur java script, j ai deja les questions mais je n arrive pas a synchroniser le bouton "submit" avec les question dans le but que lorsque je clique dessus je puisse avoir ma reussite en pourcentage, selon si j ai bien repondu aux questions ou non.
Est ce que quelqu un saurait m aider et corriger mes fautes vu mon faible niveau en html ?
merci beaucoup !

<html>
<head>
<title>Test page</title>
<script language="JavaScript">
function score(){
var score=0;
if (document.myform.r1[1].checked == true)
score++;
if (document.myform.r2[0].checked == true)
score++;
if (document.myform.r3[0].checked == true)
score++;
if (document.myform.r4[3].checked == true)
score++;
if (document.myform.r5[2].checked == true)
score++;
if (document.myform.r6[2].checked == true)
score++;

window.alert("Your score is: " + score);
}

</script>
</head>
<body>
<h1><center>IQ test</center></h1>
<form name = "myform">


<td valign="top">1.</td>
What is the name of the first US's president:<br>
Franklin D.Roosevelt<input type ="radio" name =" r1" value =1 checked><br>
George Washington<input type = "radio" name = "r1" value = 2><br>
Thomas Jefferson <input type = "radio" name = "r1" value = 3><br><br>

<td valign="top">2.</td>
Which number should come next in the series ?<br>
5-10-15-20
<br>
<br>
25<input type = "radio" name = "r2" value = 1 checked><br>
26<input type = "radio" name = "r2" value = 2><br>
30<input type = "radio" name = "r2" value = 3><br>


<br>

<td valign="top">3.</td>

"In this world nothing can be said to be certain, except death and taxes." This statement was made by Benjamin Franklin.
<br/>
<br/>
<input type = "radio" name = "r3" value =1 checked>True
<input type = "radio" name = "r3" value =2>False



<br>
<td valign="top">4.</td>
Which one of the five choices makes the best comparison?<br>WATCH is to HCTAW as 46251 is to:</td></tr><br>
<br>
<input type = "radio" name = "r4" value =1>25641<br>
<input type = "radio" name = "r4" value=2>12654<br>
<input type = "radio" name = "r4" value=3>51462<br>
<input type = "radio" name = "r4" value=4 checked>15264

<br>

<br>
<td valign="top">5.</td>
Forest is to tree as tree is to?<br>
<br>

<button class ='btn btn-test btn-test-warning btn-block btn-test-2-lines next_view' type="button" radio name = r5 value =1>Plant</button>
<br>
<button class='btn btn-test btn-test-warning btn-block btn-test-2-lines next_view' type="button" radio name = r5 value =2>Branch</button>
<br>
<button class='btn btn-test btn-test-warning btn-block btn-test-2-lines next_view' type="button" radio name = r5 value=3>Leaf</button>
<br>
<button class='btn btn-test btn-test-warning btn-block btn-test-2-lines next_view' type="button" radio name = r5 value =4>Mangrove</button>


<br>

<br>
<td valign="top">6.</td>
The day after the day after tomorrow is four days before Monday. What day is it today ?<br>

<SELECT NAME="answer1" SIZE=1>
<OPTION SELECTED VALUE="0">-- Choose the correct answer --
<OPTION VALUE="1">Tuesday
<OPTION VALUE="2">Monday
<OPTION VALUE="1">Wednesday
<OPTION VALUE="1">Thursday
</SELECT>

<br>
<input type = "button" value = "Submit" onclick = "score()">
<br>


</form>
</body></html>
A voir également:

1 réponse

mr_demonicon Messages postés 828 Date d'inscription dimanche 20 juillet 2014 Statut Membre Dernière intervention 9 avril 2016 126
10 déc. 2014 à 16:51
petite errreur a
<td valign="top">1.</td> 
What is the name of the first US's president:<br> 
Franklin D.Roosevelt<input type ="radio" name ="r1" value =1 checked><br> 
il faut enlever l'espace devant r1 sinon coche par defaut tout le temps
0