Bonjour,
Voila j'ai trouvé un calendrier JS sympa qui me permet de sélectionner x dates, par contre étant débutant en JS, je ne vois pas comment récupérer mon tableau de date pour l'affecter à une textarea ou plusieurs <input text
Auriez vous des idées ?
Voila le code JS qui affiche actuellement mes dates sélectionnées:
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 <body> <a id="trigger" href="#">[open calendar...]</a> <div id="output"></div> <script type="text/javascript"> // // the default multiple dates selected, first time the calendar is instantiated var MA = []; function closed(cal) { // here we'll write the output; this is only for example. You // will normally fill an input field or something with the dates. var el = document.getElementById("output"); // reset initial content. el.innerHTML = ""; // Reset the "MA", in case one triggers the calendar again. // CAREFUL! You don't want to do "MA = [];". We need to modify // the value of the current array, instead of creating a new one. // Calendar.setup is called only once! :-) So be careful. MA.length = 0; // walk the calendar's multiple dates selection hash for (var i in cal.multiple) { var d = cal.multiple[i]; // sometimes the date is not actually selected, that's why we need to check. if (d) { // OK, selected. Fill an input field. Or something. Just for example, // we will display all selected dates in the element having the id "output". el.innerHTML += d.print("%A, %Y %B %d") + "<br />"; // and push it in the "MA", in case one triggers the calendar again. MA[MA.length] = d; } } cal.hide(); return true; }; Calendar.setup({ align : "BR", showOthers : true, multiple : MA, // pass the initial or computed array of multiple dates to be initially selected onClose : closed, button : "trigger" }); </script> </body>
Partager