Bonjour,
je suis debutante en javascript,et jai l'exercice suivant:A l’aide des formulaires et de fonctions Javascript réalisez un QCM dont le résultat (le nombre de réponses correctes) sera affiché dans un champs texte en bas de la page.voila le code que j'ai mis mais ça donne rien je sais pas prk?.
<html>
<head>
<title>QCM</title>
<script language="javascript" type="text/javascript">
<!--
function calcul(form_qz){
var i=0
if document.form_qz.choix_rep_0.value=1;
i++;
if document.form_qz.choix_rep_1.value=1;
i++;
if document.form_qz.choix_rep_2.value=1;
i++;
if document.form_qz.choix_rep_3.value=1;
i++;
if document.form_qz.choix_rep_4.value=1;
i++;
if document.form_qz.choix_rep_5.value=1;
i++;
if document.form_qz.choix_rep_6.value=1;
i++;
if document.form_qz.choix_rep_7.value=1;
i++;
if document.form_qz.choix_rep_8.value=1;
i++;
if document.form_qz.choix_rep_9.value=1;
i++;
}
//-->
</script>
</head>
<body>
<form name="form_qz">
<p>Le colvert est :
<br><input type="radio" name="choix_rep_0" value="1">un canard
<br><input type="radio" name="choix_rep_0" value="0">un coq
<br><input type="radio" name="choix_rep_0" value="0">un perroquet
</p>
<p>Le petit-gris est:
<br><input type="radio" name="choix_rep_1" value="0">un rat
<br><input type="radio" name="choix_rep_1" value="0">un chat
<br><input type="radio" name="choix_rep_1" value="1">un escargot
</p>
<p>Quel est le nom du poisson surnommé le "cheval de mer"?
<br><input type="radio" name="choix_rep_2" value="0">Le dauphin
<br><input type="radio" name="choix_rep_2" value="1">L'hippocampe
<br><input type="radio" name="choix_rep_2" value="0">L'espadon
</p>
<p>Quelle est la capitale de l'Italie?
<br><input type="radio" name="choix_rep_3" value="0">Venise
<br><input type="radio" name="choix_rep_3" value="0">Milan
<br><input type="radio" name="choix_rep_3" value="1">Rome
</p>
<p>Quelle est la capitale de l'Espagne?
<br><input type="radio" name="choix_rep_4" value="1">Madrid
<br><input type="radio" name="choix_rep_4" value="0">Tolède
<br><input type="radio" name="choix_rep_4" value="0">Barcelone
</p>
<p>Quelle est la capitale de la Chine?
<br><input type="radio" name="choix_rep_5" value="1">Pékin
<br><input type="radio" name="choix_rep_5" value="0">Hongkong
<br><input type="radio" name="choix_rep_5" value="0">Shanghaï
</p>
<p>Quelle pâtisserie mange-t-on le plus souvent à Noël en France?
<br><input type="radio" name="choix_rep_6" value="0">La galette des rois
<br><input type="radio" name="choix_rep_6" value="1">La bûche de Noël
<br><input type="radio" name="choix_rep_6" value="0">La religieuse
</p>
<p>Est-ce que l’été est suivi immédiatement par le printemps?
<br><input type="radio" name="choix_rep_7" value="1">Non
<br><input type="radio" name="choix_rep_7" value="0">Oui
</p>
<p>Est-ce que le sel a un goût sucré?
<br><input type="radio" name="choix_rep_8" value="1">Non
<br><input type="radio" name="choix_rep_8" value="0">Oui
</p>
<p>Les pommes sont-elles toujours vertes?
<br><input type="radio" name="choix_rep_9" value="0">Oui
<br><input type="radio" name="choix_rep_9" value="1">Non
</p>
<p>le nombre de réponses correctes est :
<input type="button" name="btnAfficher" value="afficher le reslultat" onclick="document.getelementbyid('reslultat').value=calcul(form_qz)">
<br><input type="text" name="txtNb" id="resultat">
</p>
</form>
</body>
</html>
Si qualqun peut me corriger ou me proposez koi ke ce soit merci d'avance,j'attend vs reponses:)