Salut,
Je suis entrain de développez une page qui contient un certain nombre des des segment (8 segment), chaque segment contient des question. lorsque l'utilisateur click sur GO elle doit afficher le nombre de réponse "yes" pour chaque segment.
le problème quand j'ai click sur Go rien ne s'affiche .
Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<html>
<head>
	<title>Title of page</title>
	<style type="text/css">
		fieldset {
			padding:20px;
			border:3px double #000;
			}
		h1 {
			font-size:18px;
			}
		div {
		margin:15px;
			}
	</style>
	<script type="text/javascript">
	function calc()
		{
		var tabyes = new Array(); // contenir nombre des "yes" pourr chaque segment
		var tabques = new Array(9,5,1,3,3,5,3,3) // contient nombre des question dans chaque segment
		for (i=0; i<8;i++) // parcourir les segment
		 {
		    var nbyes = 0;
			for (j=0;j<tabques[i+1];j++) // parcourir les question
			 {
				if (document.form1.s[i]q[i].checked.value == 1) {nbyes++;} 
			 }
		 tabyes[i]= nbyes;
		 }
		alert(tabyes[2]); // petit test juste pour verfier si mon fonction calc foctionne 
		}
	</script>
</head>
<body>
	<form name="form1">
		<fieldset>
			<legend>Segment1: </legend>
			<h1>Question 1:</h1>
				<div>Yes<input type="radio" name="s1q1" value="1"> No<input type="radio" name="s1q1" value="0"></div>
			<h1>Question 2:</h1>
				<div>Yes<input type="radio" name="s1q2" value="1"> No<input type="radio" name="s1q2" value="0"></div>
			<h1>Question 3:</h1>
				<div>Yes<input type="radio" name="s1q3" value="1"> No<input type="radio" name="s1q3" value="0"></div>
			<h1>Question 4:</h1>
				<div>Yes<input type="radio" name="s1q4" value="1"> No<input type="radio" name="s1q4" value="0"></div>
			<h1>Question 5:</h1>
				<div>Yes<input type="radio" name="s1q5" value="1"> No<input type="radio" name="s1q5" value="0"></div>
			<h1>Question 6:</h1>
				<div>Yes<input type="radio" name="s1q6" value="1"> No<input type="radio" name="s1q6" value="0"></div>
			<h1>Question 7:</h1>
				<div>Yes<input type="radio" name="s1q7" value="1"> No<input type="radio" name="s1q7" value="0"></div>
			<h1>Question 8:</h1>
				<div>Yes<input type="radio" name="s1q8" value="1"> No<input type="radio" name="s1q8" value="0"></div>
			<h1>Question 9:</h1>
				<div>Yes<input type="radio" name="s1q9" value="1"> No<input type="radio" name="s1q9" value="0"></div>	
		</fieldset>
		<fieldset>
			<legend>Segment2: </legend>
			<h1>Question 1:</h1>
				<div>Yes<input type="radio" name="s2q1" value="1"> No<input type="radio" name="s2q1" value="0"></div>
			<h1>Question 2:</h1>
				<div>Yes<input type="radio" name="s2q2" value="1"> No<input type="radio" name="s2q2" value="0"></div>
			<h1>Question 3:</h1>
				<div>Yes<input type="radio" name="s2q3" value="1"> No<input type="radio" name="s2q3" value="0"></div>
			<h1>Question 4:</h1>
				<div>Yes<input type="radio" name="s2q4" value="1"> No<input type="radio" name="s2q4" value="0"></div>
			<h1>Question 5:</h1>
				<div>Yes<input type="radio" name="s2q5" value="1"> No<input type="radio" name="s2q5" value="0"></div>
		</fieldset>
		<fieldset>
			<legend>Segment3: </legend>
			<h1>Question 1:</h1>
				<div>Yes<input type="radio" name="s3q1" value="1"> No<input type="radio" name="s3q1" value="0"></div>
			</fieldset>
		<fieldset>
			<legend>Segment4: </legend>
			<h1>Question 1:</h1>
				<div>Yes<input type="radio" name="s4q1" value="1"> No<input type="radio" name="s4q1" value="0"></div>
			<h1>Question 2:</h1>
				<div>Yes<input type="radio" name="s4q2" value="1"> No<input type="radio" name="s4q2" value="0"></div>
			<h1>Question 3:</h1>
				<div>Yes<input type="radio" name="s4q3" value="1"> No<input type="radio" name="s4q3" value="0"></div>
		</fieldset>
		<fieldset>
			<legend>Segment5: </legend>
			<h1>Question 1:</h1>
				<div>Yes<input type="radio" name="s5q1" value="1"> No<input type="radio" name="s5q1" value="0"></div>
			<h1>Question 2:</h1>
				<div>Yes<input type="radio" name="s5q2" value="1"> No<input type="radio" name="s5q2" value="0"></div>
			<h1>Question 3:</h1>
				<div>Yes<input type="radio" name="s5q3" value="1"> No<input type="radio" name="s5q3" value="0"></div>
		</fieldset>
		<fieldset>
			<legend>Segment6: </legend>
			<h1>Question 1:</h1>
				<div>Yes<input type="radio" name="s6q1" value="1"> No<input type="radio" name="s6q1" value="0"></div>
			<h1>Question 2:</h1>
				<div>Yes<input type="radio" name="s6q2" value="1"> No<input type="radio" name="s6q2" value="0"></div>
			<h1>Question 3:</h1>
				<div>Yes<input type="radio" name="s6q3" value="1"> No<input type="radio" name="s6q3" value="0"></div>
			<h1>Question 4:</h1>
				<div>Yes<input type="radio" name="s6q4" value="1"> No<input type="radio" name="s6q4" value="0"></div>
			<h1>Question 5:</h1>
				<div>Yes<input type="radio" name="s6q5" value="1"> No<input type="radio" name="s6q5" value="0"></div>
		</fieldset>
		<fieldset>
			<legend>Segment7: </legend>
			<h1>Question 1:</h1>
				<div>Yes<input type="radio" name="s7q1" value="1"> No<input type="radio" name="s7q1" value="0"></div>
			<h1>Question 2:</h1>
				<div>Yes<input type="radio" name="s7q2" value="1"> No<input type="radio" name="s7q2" value="0"></div>
			<h1>Question 3:</h1>
				<div>Yes<input type="radio" name="s7q3" value="1"> No<input type="radio" name="s7q3" value="0"></div>
		</fieldset>
		<fieldset>
			<legend>Segment8: </legend>
			<h1>Question 1:</h1>
				<div>Yes<input type="radio" name="s8q1" value="1"> No<input type="radio" name="s8q1" value="0"></div>
			<h1>Question 2:</h1>
				<div>Yes<input type="radio" name="s8q2" value="1"> No<input type="radio" name="s8q2" value="0"></div>
			<h1>Question 3:</h1>
				<div>Yes<input type="radio" name="s8q3" value="1"> No<input type="radio" name="s8q3" value="0"></div>
		</fieldset>
		<input type="button" value="GO" onclick="calc()">
	</form>
</body>
</html>