Bonsoir,

mon code permet de renseigner une date de début et une date de fin. J'ai donc 2 champs Datepicker. Le premier fonctionne mais pas le second (quand on clique dessus, pas de calendrier). Pourtant les 2 codes sont similaires; Qu'est-ce qui ne va pas ?

Code html : 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<head><link href="http://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
	<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
	<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
	<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
	<link rel="stylesheet" href="/resources/demos/style.css">
  <link href="<?php echo SITE_URL_HTTP; ?>/css/bootstrap.css" rel="stylesheet"/> <!-- après le css de bootstrap -->
</head>
<body>
…
 
<table>
    <tr>
	<td><?php echo $str[302];?> : </td>
	<td> 
	<input type="text" class="form-control datepicker" id="datepickerd" name="datepickerd" placeholder="<?php echo $str[361];?>">	
	</td>
    <td><?php echo $str[313];?></td></tr>
 
    <tr>
	<td><?php echo $str[303];?> : </td>
	<td> 
	<input type="text" class="form-control datepicker" id="datepickerf" name="datepickerf" placeholder="<?php echo $str[361];?>">	
	</td>
	<td><?php echo $str[313];?></td></tr>
</table>
 
 
<script>
    $(document).ready(function(){ // signifie : QUAND LE DOM EST PRET (= APRES chargement de la page)
        $('#datepickerd').datepicker({ 
            dateFormat: 'dd-mm-yy', firstDay:1, minDate: new Date(),
            onSelect: function() {
                if( $('#datepickerf').val() == '' )
                {
                    $('#datepickerf').val( $(this).val() );
                }
            },
 
            changeMonth: true,
 
            changeYear: true            
            });
    });
</script>
 
<?php if ($lang=='fr'){ ?>
        <script>
                    (function($){
                    $.fn.datepicker.dates['fr'] = {
                    days: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
                    daysShort: ["dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."],
                    daysMin: ["d", "l", "ma", "me", "j", "v", "s"],
                    months: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"],
                    monthsShort: ["janv.", "févr.", "mars", "avril", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."],
                    today: "Aujourd'hui",
                    monthsTitle: "Mois",
                    clear: "Effacer",
                    weekStart: 1,
                    format: "dd/mm/yyyy"
                    };
                    }(jQuery));
    
    
    
                    $('.datepicker').datepicker({
                    language: 'fr',
                    autoclose: true,
                    todayHighlight: true
                    })
        </script>
            <?php }
            else {
            ?>
        <script>
                    (function($){
                    $.fn.datepicker.dates['en'] = {
                    days: ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"],
                    daysShort: ["sun.", "mon.", "tue.", "wed.", "thu.", "fri.", "sat."],
                    daysMin: ["su", "m", "tu", "w", "th", "f", "sa"],
                    months: ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"],
                    monthsShort: ["jan.", "feb.", "mar.", "apr.", "may", "june", "july", "aug.", "sept.", "oct.", "nov.", "dec."],
                    today: "Today",
                    monthsTitle: "Month",
                    clear: "Clear",
                    weekStart: 1,
                    format: "mm/dd/yyyy"
                    };
                    }(jQuery));
 
 
                    $('.datepicker').datepicker({
                    language: 'en',
                    autoclose: true,
                    todayHighlight: true
                    })
        </script>
            <?php
            } ?>

Quand j'ai écrit ce code, je ne savais pas encore qu'on ne fait plus de mise en page avec <table> et j'ai pas envie de toucher à cette partie du code qui fonctionne.

Manque-t-il une déclaration de js ?