Tuto créer un calendrier

Par mouadh1988, il y a 11 ans


Bonjour,

magnifique tuto,"http://www.youtube.com/watch?v=wjF7vP\_cudg"
Par contre mon script ne fonctionne pas. J'ai peut-être fait une erreur en recopiant. Ça fonctionne jusqu'à l'affichage du mois de janvier, mais rien ne se passe quand je clique sur

4 réponses

mouadh1988, il y a 11 ans
<head>
        <meta http-equiv="Content-Type" content="text/html"; charset="UTF-8">
        <title>calendrier</title>
        <link type="text/css" rel="stylesheet" href="style.css">

       <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
       <script type="text/javascript">

            jQuery(function($){
               $('.month').hide();
               $('.month:first').show();
               $('.months a:first').addClass('active');
               var current = 1;
               $('.months a').click(function(){
                    var month = $(this).attr('id').replace('linkMonth','');
                    if(month != current){
                        $('#month'+current).slideUp();
                        $('#month'+month).slideDown();
                        $('.months a').removeClass('active'); 
                        $('.months a#linkMonth'+month).addClass('active'); 
                        current = month;
                    }
                    return false; 
               });
            });

       </script>
    </head>
mouadh1988, il y a 11 ans
<body>
        <?php
        require ('date.php');
        $date = new Date();
        $year = date('Y');
        $dates = $date->getAll($year);
        ?>
        <div class="periods">
            <div class="year"><?php echo $year; ?></div>
            <div class="months">
                <ul>
                    <?php foreach ($date->months as $id => $m): ?>
                        <li><a href="#" id="linkMonth<?php echo $id + 1; ?>"><?php echo utf8_encode(substr(utf8_decode($m), 0, 3)); ?></a></li>
                    <?php endforeach; ?>
                </ul>
            </div>
            <div class="clear"></div>
            <?php $dates = current($dates); ?>
            <?php foreach ($dates as $m => $days): ?>
                <div class="month" id="month <?php echo $m; ?>">
                    <table>
                        <thead>
                            <tr>
                                <?php foreach ($date->days as $d): ?>
                                    <th><?php echo substr($d, 0, 3); ?></th>
                                <?php endforeach; ?>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <?php $end = end($days);
                                foreach($days as $d => $w): ?>
                                    <?php if($d == 1 and $w != 1): ?>
                                        <td colspan="<?php echo $w - 1; ?>" class="padding"></td>
                                    <?php endif; ?>
                                    <td>
                                        <div class="relative">
                                            <div class="day"><?php echo $d; ?>
                                            </div>
                                        </div>
                                    </td>
                                    <?php if ($w == 7): ?>
                                    </tr>
                                    <tr>
                                    <?php endif; ?> 
                                <?php endforeach; ?>
                                <?php if ($end != 7): ?>
                                    <td colspan="<?php echo 7 - $end; ?>" class="padding"></td>

                                    <?php endif; ?> 
                            </tr>
                        </tbody>
                    </table>
                </div>
<?php endforeach; ?>
        </div>
        <pre><?php print_r($dates); ?></pre>
    </body>
mouadh1988, il y a 11 ans

le problème :
Ça fonctionne jusqu'à l'affichage du mois de janvier, mais rien ne se passe quand je clique sur un autre mois.

mouadh1988, il y a 11 ans

merci je trouver le pommelée et j'ai corriger ;)