J'essaye de modifier un calendrier et de l'adapter pour mon site mais je bloque à un endroit
Le calendrier utilise de l'ajax
Voici le code ma fonction calendrier
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 function calendrier($mois,$annee) //renvoi un calendrier { //variables $date = date('Y-m-01'); $moi = date('n'); $year = date('Y'); $ts = mktime(1,1,1,$mois,1,$annee); //Recuperation du timestamp du numero du jour de base cad le numero du jour du premier jour du mois ouf ! $tab = getdate($ts); //Recuperation du numero du jour de base, le numero du jour du premier jour du mois $j = 1 ; //premier jour $nbjour = date('t',$ts) ;//nombre de jour dans le mois $nom_mois = array('Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobtre','Novembre','Décembre');//Nom des moins in French //cette sequence corrige le numero du dimanche. PHP donne 0, dans notre cas 7 est préférable, donc.. if($tab['wday'] == 0) { $dp = 7 ; } else { $dp = $tab['wday'] ; } $moiprochain = date('Y-m-d',strtotime($date . '+1 month')); $moiapresedent = date('Y-m-d',strtotime($date . '-1 month')); //Affichage de l'entête du calendrier echo '<table width="100%" border="1"><tr><td align="center" colspan="7" class="calendrier-mois"><a href="#" onclick="updatelistdate(\''.$moiapresedent.'\')"><b><</b></a> <b>'.$nom_mois[$mois-1].' '.$year.'</b> <a href="#" onclick="updatelistdate(\''.$moiprochain.'\')"><b>></b></a></td></tr>'; echo "<tr><td>Lun</td><td>Mar</td><td>Mer</td><td>Jeu</td><td>Ven</td><td>Sam</td><td>Dim</td></tr>"; //Affichage du calendrier for($i=1;$i<=42;$i++) { if($i % 7 == 1 ) //si il reste un, on commence forcement une nouvelle ligne { echo "<tr>"; } for($f = $date ; $f < $moiprochain ;$f = date('Y-m-d',strtotime($f . '+1 day'))) { if(($dp <= $i)&&($j <= $nbjour))//si nous sommes apres le numero du premier jour et que nous n avons pas {//passé le 30 ou 31 echo '<td><a href="#" onclick="updatedate(\''.$f.'\')">'.$j.'</a></td>' ; //on affiche $j++; } else { echo "<td></td>"; //sinon case vide } } if($i % 7 == 0 ) //si il ne reste rien, cad des multiples de 7, on se retrouve forcement en fin de ligne { echo "</tr>"; } } echo "</table>"; //affichage de la fin du tableau //calcul des positions des mois //barre de navigation } //Fin fonction
Le problème que j'ai c'est avec la ligne suivante
for($f = $date ; $f < $moiprochain ;$f = date('Y-m-d',strtotime($f . '+1 day'))) {
J'ai besoin de récupèré la variable f pour la fonction updatedate en ajax, le problème c'est que je ne sais pas ou placer cette ligne pour que mon calendrier s'affiche correctement
Actuellement elle recupere bien la variable mais elle m'affiche mon calendrier sur un seul <tr> et une multitude de <td>
Je souhaiterais que le calendrier s'affiche comme tous les calendrier c'est à dire un <tr> par semaine
Voici ce que ça me donne en résultat
Si je deplace ma ligne de cette manière
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <table border="1" width="100%"><tbody><tr><td align="center" class="calendrier-mois" colspan="7"><a onclick="updatelistdate('2011-07-01')" href="#"><b><</b></a> <b>Ao�t 2011</b> <a onclick="updatelistdate('2011-09-01')" href="#"><b>></b></a></td></tr><tr><td>Lun</td><td>Mar</td><td>Mer</td><td>Jeu</td><td>Ven</td><td>Sam</td><td>Dim</td></tr><tr><td><a onclick="updatedate('2011-08-01')" href="#">1</a></td><td><a onclick="updatedate('2011-08-02')" href="#">2</a></td><td><a onclick="updatedate('2011-08-03')" href="#">3</a></td><td><a onclick="updatedate('2011-08-04')" href="#">4</a></td><td><a onclick="updatedate('2011-08-05')" href="#">5</a></td><td><a onclick="updatedate('2011-08-06')" href="#">6</a></td><td><a onclick="updatedate('2011-08-07')" href="#">7</a></td><td><a onclick="updatedate('2011-08-08')" href="#">8</a></td><td><a onclick="updatedate('2011-08-09')" href="#">9</a></td><td><a onclick="updatedate('2011-08-10')" href="#">10</a></td><td><a onclick="updatedate('2011-08-11')" href="#">11</a></td><td><a onclick="updatedate('2011-08-12')" href="#">12</a></td><td><a onclick="updatedate('2011-08-13')" href="#">13</a></td><td><a onclick="updatedate('2011-08-14')" href="#">14</a></td><td><a onclick="updatedate('2011-08-15')" href="#">15</a></td><td><a onclick="updatedate('2011-08-16')" href="#">16</a></td><td><a onclick="updatedate('2011-08-17')" href="#">17</a></td><td><a onclick="updatedate('2011-08-18')" href="#">18</a></td><td><a onclick="updatedate('2011-08-19')" href="#">19</a></td><td><a onclick="updatedate('2011-08-20')" href="#">20</a></td><td><a onclick="updatedate('2011-08-21')" href="#">21</a></td><td><a onclick="updatedate('2011-08-22')" href="#">22</a></td><td><a onclick="updatedate('2011-08-23')" href="#">23</a></td><td><a onclick="updatedate('2011-08-24')" href="#">24</a></td><td><a onclick="updatedate('2011-08-25')" href="#">25</a></td><td><a onclick="updatedate('2011-08-26')" href="#">26</a></td><td><a onclick="updatedate('2011-08-27')" href="#">27</a></td><td><a onclick="updatedate('2011-08-28')" href="#">28</a></td><td><a onclick="updatedate('2011-08-29')" href="#">29</a></td><td><a onclick="updatedate('2011-08-30')" href="#">30</a></td><td><a onclick="updatedate('2011-08-31')" href="#">31</a></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>..........
Mon calendrier s'affiche un peu près correctement mais il ne me récupère pas ma variable correctement voici le résultat à l'affichage
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 function calendrier($mois,$annee) //renvoi un calendrier { //variables $date = date('Y-m-01'); $moi = date('n'); $year = date('Y'); $ts = mktime(1,1,1,$mois,1,$annee); //Recuperation du timestamp du numero du jour de base cad le numero du jour du premier jour du mois ouf ! $tab = getdate($ts); //Recuperation du numero du jour de base, le numero du jour du premier jour du mois $j = 1 ; //premier jour $nbjour = date('t',$ts) ;//nombre de jour dans le mois $nom_mois = array('Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobtre','Novembre','Décembre');//Nom des moins in French //cette sequence corrige le numero du dimanche. PHP donne 0, dans notre cas 7 est préférable, donc.. if($tab['wday'] == 0) { $dp = 7 ; } else { $dp = $tab['wday'] ; } $moiprochain = date('Y-m-d',strtotime($date . '+1 month')); $moiapresedent = date('Y-m-d',strtotime($date . '-1 month')); //Affichage de l'entête du calendrier echo '<table width="100%" border="1"><tr><td align="center" colspan="7" class="calendrier-mois"><a href="#" onclick="updatelistdate(\''.$moiapresedent.'\')"><b><</b></a> <b>'.$nom_mois[$mois-1].' '.$year.'</b> <a href="#" onclick="updatelistdate(\''.$moiprochain.'\')"><b>></b></a></td></tr>'; echo "<tr><td>Lun</td><td>Mar</td><td>Mer</td><td>Jeu</td><td>Ven</td><td>Sam</td><td>Dim</td></tr>"; //Affichage du calendrier for($f = $date ; $f < $moiprochain ;$f = date('Y-m-d',strtotime($f . '+1 day'))) { for($i=1;$i<=42;$i++) { if($i % 7 == 1 ) //si il reste un, on commence forcement une nouvelle ligne { echo "<tr>"; } if(($dp <= $i)&&($j <= $nbjour))//si nous sommes apres le numero du premier jour et que nous n avons pas {//passé le 30 ou 31 echo '<td><a href="#" onclick="updatedate(\''.$f.'\')">'.$j.'</a></td>' ; //on affiche $j++; } else { echo "<td></td>"; //sinon case vide } if($i % 7 == 0 ) //si il ne reste rien, cad des multiples de 7, on se retrouve forcement en fin de ligne { echo "</tr>"; } } } echo "</table>"; //affichage de la fin du tableau //calcul des positions des mois //barre de navigation } //Fin fonction
Si quelqu'un voit ou se situe le problème, d'avance merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <table border="1" width="100%"><tbody><tr><td align="center" class="calendrier-mois" colspan="7"><a onclick="updatelistdate('2011-07-01')" href="#"><b><</b></a> <b>Ao�t 2011</b> <a onclick="updatelistdate('2011-09-01')" href="#"><b>></b></a></td></tr><tr><td>Lun</td><td>Mar</td><td>Mer</td><td>Jeu</td><td>Ven</td><td>Sam</td><td>Dim</td></tr><tr><td><a onclick="updatedate('2011-08-01')" href="#">1</a></td><td><a onclick="updatedate('2011-08-01')" href="#">2</a></td><td><a onclick="updatedate('2011-08-01')" href="#">3</a></td><td><a onclick="updatedate('2011-08-01')" href="#">4</a></td><td><a onclick="updatedate('2011-08-01')" href="#">5</a></td><td><a onclick="updatedate('2011-08-01')" href="#">6</a></td><td><a onclick="updatedate('2011-08-01')" href="#">7</a></td></tr><tr><td><a onclick="updatedate('2011-08-01')" href="#">8</a></td><td><a onclick="updatedate('2011-08-01')" href="#">9</a></td><td><a onclick="updatedate('2011-08-01')" href="#">10</a></td><td><a onclick="updatedate('2011-08-01')" href="#">11</a></td><td><a onclick="updatedate('2011-08-01')" href="#">12</a></td><td><a onclick="updatedate('2011-08-01')" href="#">13</a></td><td><a onclick="updatedate('2011-08-01')" href="#">14</a></td></tr><tr><td><a onclick="updatedate('2011-08-01')" href="#">15</a></td><td><a onclick="updatedate('2011-08-01')" href="#">16</a></td><td><a onclick="updatedate('2011-08-01')" href="#">17</a></td><td><a onclick="updatedate('2011-08-01')" href="#">18</a></td><td><a onclick="updatedate('2011-08-01')" href="#">19</a></td><td><a onclick="updatedate('2011-08-01')" href="#">20</a></td><td><a onclick="updatedate('2011-08-01')" href="#">21</a></td></tr><tr><td><a onclick="updatedate('2011-08-01')" href="#">22</a></td><td><a onclick="updatedate('2011-08-01')" href="#">23</a></td><td><a onclick="updatedate('2011-08-01')" href="#">24</a></td><td><a onclick="updatedate('2011-08-01')" href="#">25</a></td><td><a onclick="updatedate('2011-08-01')" href="#">26</a></td><td><a onclick="updatedate('2011-08-01')" href="#">27</a></td><td><a onclick="updatedate('2011-08-01')" href="#">28</a></td></tr><tr><td><a onclick="updatedate('2011-08-01')" href="#">29</a></td><td><a onclick="updatedate('2011-08-01')" href="#">30</a></td><td><a onclick="updatedate('2011-08-01')" href="#">31</a></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td>.........</tr></tbody></table>
Partager