Bonjour
j'ai actuellement 12 functions
etc...
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 $('#pax-1').click(function() { pax = '1'; $('#vpax').val(pax); $('#pax').html(pax); reservation(); }); $('#pax-2').click(function() { pax = '2'; $('#vpax').val(pax); $('#pax').html(pax); reservation(); }); $('#pax-3').click(function() { pax = '3'; $('#vpax').val(pax); $('#pax').html(pax); reservation(); });
je voudrais faire une boucle de 1 à 12
Mais ça ne fonctionne pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 for ($i = 1; $i <= 12; $i=$i+1) { var fct = "$("+"'#pax-" + $i + "').click(function() {"; fct =fct+ "pax = '" + $i + "';"; fct =fct+ "$('#vpax').val(pax);"; fct =fct+ "$('#pax').html(pax);"; fct =fct+ "reservation();"; fct =fct+"});"; fonction = new Function(fct); fonction(); }
Merci pour votre aide
Partager