bonjour,
j'ai un petit probl�me avec la r�alisation d'un switch

j'ai 3 boutons sur ma page qui appellent qui chacun une fonction qui modifie la variable "choix".
en fonction de choix, on rentre ensuite dans une des propositions du switch.
le probl�me vient de celui-ci puisque sans le switch, le code fonctionne.

declaration
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
 
var tuile = new Array(3);
for (var i=0; i < tuile.length;i++) //img tuile
	tuile[i] = new Image();
tuile[0].src='photo/photo1.jpg';
tuile[1].src='photo/photo2.jpg';
tuile[2].src='photo/photo3.jpg';
 
var presentation = new Array(3);		   
for (var i=0; i < presentation.length;i++) //img presentation
	presentation[i] = new Image();
presentation[0].src='photo/photo1.jpg';
presentation[1].src='photo/photo2.jpg';
presentation[2].src='photo/photo3.jpg';
 
var ardoise = new Array(3);		   
for (var i=0; i < ardoise.length;i++) //img ardoise
	ardoise[i] = new Image();
ardoise[0].src='photo/photo1.jpg';
ardoise[1].src='photo/photo2.jpg';
ardoise[2].src='photo/photo3.jpg';
 
var divers = new Array(3);		    
for (var i=0; i < divers.length;i++) //img divers
	divers[i] = new Image();
divers[0].src='photo/photo1.jpg';
divers[1].src='photo/photo2.jpg';
divers[2].src='photo/photo3.jpg';
 
var text = new Array;
text[0] = "Toiture 1";
text[1] = "Toiture 2";
text[2] = "Toiture 3";
 
var n=0;
var choix=4;
fonctions
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
 
function tuile()
{
	choix = 1;
}
 
function ardoise()
{
	choix = 2;
}
 
function divers()
{
	choix = 3;
}
 
function next() 
{
	n= ++n;
	switch choix
	{
		case 1:
			if (n == tuile.length) n=0;
			window.document.move.src= tuile[n].src;
			document.getElementById('bloc').innerHTML= text[n];
		break;
		case 2:
			if (n == ardoise.length) n=0;
			window.document.move.src= ardoise[n].src;
			document.getElementById('bloc').innerHTML= text[n];
		break;
		case 3:
			if (n == divers.length) n=0;
			window.document.move.src= divers[n].src;
			document.getElementById('bloc').innerHTML= text[n];
		break;
		case 4:
			if (n == presentation.length) n=0;
			window.document.move.src= presentation[n].src;
			document.getElementById('bloc').innerHTML= text[n];
		break;
		default:
			alert("freestyle");
		break;
	}
}