Reedité :arrow:
Version imprimable
Reedité :arrow:
Salut all j'ai quelques difficultés sur un script à modifier un script que je doit adapté a l'usage que doit en faire mon entreprise. Etant stagiaire et n'ayant pas trop de compétence en javascrip je vous serait vraiment reconnaissant de m'aider ...
l'image montre le resultat auquel je trime pour y arriver
Virer le choix de date et reunir le siecle avec l'année
http://img78.imageshack.us/img78/3909/calendrier1vf.jpg
Si j'essaye d'enlevé un menu déroulant, ca bugge tout le script :?: ..
Une aide, un conseil, un lien vers bon tutorial...n'importe quoi mais SVP aidez-moi .
Code:
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195 <SCRIPT LANGUAGE="JavaScript"> var HTMLCode = ""; var DaysList = new Array("Jour_Vide", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"); var MonthsList = new Array("Mois_Vide", "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"); var MonthLength = new Array("Mois_longueur_vide",31,29,31,30,31,30,31,31,30,31,30,31); var QueryMonth = 0; /* Mois demande*/ var QueryYear = 0; /* Annee demandee*/ var QueryDay = 0; /* Jour de la semaine du jour demande, inconnu*/ var FirstDay = 0; /* Jour de la semaine du 1er jour du mois*/ var WeekOne = 0; /* Numerotation des semaines*/ var Today = new Date(); var TodaysYear = Today.getYear(); var TodaysMonth = Today.getMonth() + 1; var TodaysDate = Today.getDate(); var TodaysDay = Today.getDay() + 1; /* On commence par verifier les donnees fournies par l'utilisateur*/ function CheckData() { QueryDate = document.Cal.Date.selectedIndex + 1; QueryMonth = document.Cal.Month.selectedIndex + 1; QueryYear = (document.Cal.Century.selectedIndex + 15) * 100 + document.Cal.Year.selectedIndex; /* on teste la date choisie */ if (MonthLength[QueryMonth] < QueryDate) /* on verifie si la date est coherente*/ { CheckData(); } else { DisplaySchedule(); } } /* Renvoie le numero de la semaine correspondant a la date requise*/ function DefWeekNum(dd) { numd = 0; numw = 0; for (n=1; n<QueryMonth; n++) { numd += MonthLength[n]; } numd = numd + dd - (9 - DefDateDay(QueryYear,1,1)); numw = Math.floor(numd / 7) + 1; if (DefDateDay(QueryYear,1,1) == 1) { numw++; } return numw; } /* Renvoie le numero du jour de la semaine correspondant a la date requise */ function DefDateDay(yy,mm,dd) { return Math.floor((Date2Days(yy,mm,dd)-2) % 7) + 1; } /* Transforme la date en nb de jours theoriques */ function Date2Days(yy,mm,dd) { if (mm > 2) { var bis = Math.floor(yy/4) - Math.floor(yy/100) + Math.floor(yy/400); var zy = Math.floor(yy * 365 + bis); var zm = (mm-1) * 31 - Math.floor(mm * 0.4 + 2.3); return (zy + zm + dd); } else { var bis = Math.floor((yy-1)/4) - Math.floor((yy-1)/100) + Math.floor((yy-1)/400); var zy = Math.floor(yy * 365 + bis); return (zy + (mm-1) * 31 + dd); } } /* Produit le code HTML qui formera le calendrier */ function DisplaySchedule() { HTMLCode = "<table cellspacing=0 cellpadding=3 border=3 bordercolor=#000033>"; QueryDay = DefDateDay(QueryYear,QueryMonth,QueryDate); WeekOne = DefWeekNum(1); HTMLCode += "<tr align=center><td colspan=8 class=TITRE><b>" + MonthsList[QueryMonth] + " " + QueryYear + "</b></td></tr><tr align=center>"; for (s=1; s<8; s++) { if (QueryDay == s) { HTMLCode += "<td><b><font color=#ff0000>" + DaysList[s] + "</font></b></td>"; } else { HTMLCode += "<td><b>" + DaysList[s] + "</b></td>"; } } HTMLCode += "<td><b><font color=#888888>Sem</font></b></td></tr>"; a = 0; for (i=(1-DefDateDay(QueryYear,QueryMonth,1)); i<MonthLength[QueryMonth]; i++) { HTMLCode += "<tr align=center>"; for (j=1; j<8; j++) { if ((i+j) <= 0) { HTMLCode += "<td> </td>"; } else if ((i+j) == QueryDate) { HTMLCode += "<td><b><font color=#ff0000>" + (i+j) + "</font></b></td>"; } else if ((i+j) > MonthLength[QueryMonth]) { HTMLCode += "<td> </td>"; } else { HTMLCode += "<td>" + (i+j) + "</td>"; } } HTMLCode += "<td><font color=#888888><b><a target='droite' href='page3.htm'>" + (WeekOne+a+1) + "</a></b></font></td>"; //<a href="#"onClick="javascript:window.open ('') </a> HTMLCode += "</tr>"; a++; i = i + 6; } Calendrier.innerHTML = HTMLCode + "</table>"; } </SCRIPT> <STYLE type="text/css"> <!-- SELECT, INPUT, TABLE { font-family : Verdana; font-size : 10px; color : #000033; } .TITRE { font-family : Verdana; font-size : 12px; color : #000033; } --> </STYLE> </head> <body> </p> <form name="Cal"><center> <br><br><br><h3><font color="#006600">PLANNING SI@12</font></h3> <script language="JavaScript1.2" type="text/javascript"> /* AFFICHE LES 4 MENUS DEROULANTS PERMETTANT DE SELECTIONNER LE JOUR, LE MOIS ET L'ANNEE **************************************************/ DateText = "<select name=\"Date\">" for (d=1; d<32; d++) { DateText += "<option"; if (d == TodaysDate) { DateText += " SELECTED"; } DateText += ">"; if (d < 10) { DateText += "0"; } DateText += d + "</option>"; } DateText += "</select>"; /*************************************************/ MonthText = "<select name=\"Month\">" for (m=1; m<13; m++) { MonthText += "<option"; if (m == TodaysMonth) { MonthText += " SELECTED"; } MonthText += ">"; MonthText += MonthsList[m] + "</option>"; } MonthText += "</select>"; /*************************************************/ CenturyText = "<select name=\"Century\">" for (c=15; c<25; c++) { CenturyText += "<option"; if (c == Math.floor(TodaysYear / 100)) { CenturyText += " SELECTED"; } CenturyText += ">" + c + "</option>"; } CenturyText += "</select>"; /*************************************************/ YearText = "<select name=\"Year\">"; for (y=0; y<100; y++) { YearText += "<option"; if (y == (TodaysYear - Math.floor(TodaysYear / 100) * 100)) { YearText += " SELECTED"; } YearText += ">"; if (y < 10) { YearText += "0"; } YearText += y + "</option>"; } YearText += "</select>"; /*************************************************/ </script> <input type="button" value="Aujourd'hui" style="font-weight: bold" onClick="document.Cal.reset();CheckData()"> <br><br><br> <script> document.write(DateText + MonthText + CenturyText + YearText); document.write ( "Mois en cours : " + QueryDay + "<br>"); </script> <input type="button" value=" OK " style="font-weight: bold" onClick="CheckData()"><br><br> <div id="Calendrier"></div> </center></form> <script language="JavaScript1.2" type="text/javascript">CheckData()</script> </body> </html>
Si tu veux enlever la liste déroulante modifie aussi les variables
Citation:
QueryYear
CenturyText
PS : Arrêtes d'utiliser cette usine à gaz.
PS2 : change de stage