Calendrier probléme instantiation variable
Bonjour, voila depuis un petit moment que j'essaye d'alimenter un champs de mon formulaire avec la date précise d'un calendrier.
J'ai cherché dans pas mal de poste sur le forum, sur googleetc ...puis j'ai trouver une réponse ....
http://www.toulouse-renaissance.net/...formulaire.htm
Donc je suis ce qui est dit dans le tutoriel, mais je n'arrive pas à ouvrir une popup pour afficher mon calendrier.
voici sous IE l'erreur que j'ai :
'document.forms.lot_tma.elements' a la valeur Null ou n'est pas un objet
voici le code placer comme dans le tutorial :
1) dans <head>
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 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="fr" />
<title><?php echo $titresite." - ".$slogan; ?></title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<!-- DEBUT SCRIPT CALENDRIER -->
<!-- European format dd-mm-yyyy -->
<script type="text/javascript" language="JavaScript">
// Title: Tigra Calendar
// URL: http://www.softcomplex.com/products/tigra_calendar/
// Version: 3.3 (European date format)
// Date: 09/01/2005 (mm/dd/yyyy)
// Note: Permission given to use this script in ANY kind of applications if
// header lines are left unchanged.
// if two digit year input dates after this year considered 20 century.
var NUM_CENTYEAR = 30;
// is time input control required by default
var BUL_TIMECOMPONENT = false;
// are year scrolling buttons required by default
var BUL_YEARSCROLL = true;
var calendars = [];
var RE_NUM = /^\-?\d+$/;
function calendar1(obj_target) {
// assigning methods
this.gen_date = cal_gen_date1;
this.gen_time = cal_gen_time1;
this.gen_tsmp = cal_gen_tsmp1;
this.prs_date = cal_prs_date1;
this.prs_time = cal_prs_time1;
this.prs_tsmp = cal_prs_tsmp1;
this.popup = cal_popup1;
// validate input parameters
if (!obj_target)
return cal_error("Error calling the calendar: no target control specified");
if (obj_target.value == null)
return cal_error("Error calling the calendar: parameter specified is not valid target control");
this.target = obj_target;
this.time_comp = BUL_TIMECOMPONENT;
this.year_scroll = BUL_YEARSCROLL;
// register in global collections
this.id = calendars.length;
calendars[this.id] = this;
}
function cal_popup1 (str_datetime) {
if (str_datetime) {
this.dt_current = this.prs_tsmp(str_datetime);
}
else {
this.dt_current = this.prs_tsmp(this.target.value);
this.dt_selected = this.dt_current;
}
if (!this.dt_current) return;
var obj_calwindow = window.open(
'calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id,
'Calendar', 'width=200,height='+(this.time_comp ? 215 : 190)+
',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes'
);
obj_calwindow.opener = window;
obj_calwindow.focus();
}
// timestamp generating function
function cal_gen_tsmp1 (dt_datetime) {
return(this.gen_date(dt_datetime) + ' ' + this.gen_time(dt_datetime));
}
// date generating function
function cal_gen_date1 (dt_datetime) {
return (
(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "-"
+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "-"
+ dt_datetime.getFullYear()
);
}
// time generating function
function cal_gen_time1 (dt_datetime) {
return (
(dt_datetime.getHours() < 10 ? '0' : '') + dt_datetime.getHours() + ":"
+ (dt_datetime.getMinutes() < 10 ? '0' : '') + (dt_datetime.getMinutes()) + ":"
+ (dt_datetime.getSeconds() < 10 ? '0' : '') + (dt_datetime.getSeconds())
);
}
// timestamp parsing function
function cal_prs_tsmp1 (str_datetime) {
// if no parameter specified return current timestamp
if (!str_datetime)
return (new Date());
// if positive integer treat as milliseconds from epoch
if (RE_NUM.exec(str_datetime))
return new Date(str_datetime);
// else treat as date in string format
var arr_datetime = str_datetime.split(' ');
return this.prs_time(arr_datetime[1], this.prs_date(arr_datetime[0]));
}
// date parsing function
function cal_prs_date1 (str_date) {
var arr_date = str_date.split('-');
if (arr_date.length != 3) return cal_error ("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy.");
if (!arr_date[0]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
if (!RE_NUM.exec(arr_date[0])) return cal_error ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
if (!arr_date[1]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
if (!RE_NUM.exec(arr_date[1])) return cal_error ("Invalid month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
if (!arr_date[2]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
if (!RE_NUM.exec(arr_date[2])) return cal_error ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");
var dt_date = new Date();
dt_date.setDate(1);
if (arr_date[1] < 1 || arr_date[1] > 12) return cal_error ("Invalid month value: '" + arr_date[1] + "'.\nAllowed range is 01-12.");
dt_date.setMonth(arr_date[1]-1);
if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900);
dt_date.setFullYear(arr_date[2]);
var dt_numdays = new Date(arr_date[2], arr_date[1], 0);
dt_date.setDate(arr_date[0]);
if (dt_date.getMonth() != (arr_date[1]-1)) return cal_error ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+".");
return (dt_date)
}
// time parsing function
function cal_prs_time1 (str_time, dt_date) {
if (!dt_date) return null;
var arr_time = String(str_time ? str_time : '').split(':');
if (!arr_time[0]) dt_date.setHours(0);
else if (RE_NUM.exec(arr_time[0]))
if (arr_time[0] < 24) dt_date.setHours(arr_time[0]);
else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed range is 00-23.");
else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed values are unsigned integers.");
if (!arr_time[1]) dt_date.setMinutes(0);
else if (RE_NUM.exec(arr_time[1]))
if (arr_time[1] < 60) dt_date.setMinutes(arr_time[1]);
else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed range is 00-59.");
else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed values are unsigned integers.");
if (!arr_time[2]) dt_date.setSeconds(0);
else if (RE_NUM.exec(arr_time[2]))
if (arr_time[2] < 60) dt_date.setSeconds(arr_time[2]);
else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed range is 00-59.");
else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed values are unsigned integers.");
dt_date.setMilliseconds(0);
return dt_date;
}
function cal_error (str_message) {
alert (str_message);
return null;
}
</script>
<!-- FIN SCRIPT CALENDRIER -->
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" style="font-size: 8pt; font-family: Verdana" background="images/<?php echo $theme; ?>/fond.jpg" link="#000000" vlink="#000000" alink="#000000">
<div align="center">
<table border="1" style="border-collapse: collapse" width="960" id="table2" bordercolor="#BDD1EC" height="508">
<tr>
<td>
<table border="0" style="border-collapse: collapse" width="100%" id="table3" height="100%" bgcolor="#FFFFFF">
<tr>
<td colspan="4" background="images/<?php echo $theme; ?>/ban.jpg" height="253">
<p align="right">
<font color="#FFFFFF"><b><?php echo $slogan; ?></b></font><b><font color="#FFFFFF"> </font><br />
</p>
<p align="right">
<br />
</p>
<p align="left">
<font face="Tahoma" size="7" color="#FFFFFF"><b> <?php echo $titresite ?></b></font>
</p>
</td>
</tr>
<tr>
<td width="1%" height="90"> </td>
<td width="18%" height="90" valign="top">
<table border="1" style="border-collapse: collapse" width="100%" id="table13" bordercolor="#BDD1EC" height="22">
<tr>
<td background="images/<?php echo $theme; ?>/top.jpg" height="22" align="left">
<p align="center">
<font size="2" color="#0F3A7F">
<b>Navigation</b></font></td>
</tr>
<tr>
<td height="22" align="left">
<font size="2"> <img border="0" src="images/<?php echo $theme; ?>/fleche.gif"></font><b><font size="2" color="#0F3A7F">
</font><a href="?">
<font size="2" color="#0F3A7F">
<span style="text-decoration: none">
Accueil</span></font></a></b></td>
</tr>
<tr>
<td height="22" align="left">
<font size="2"> <img border="0" src="images/<?php echo $theme; ?>/fleche.gif"> </font>
<b>
<font size="2" color="#0F3A7F">
<a href="?action=Forum">
<font color="#0F3A7F">
<span style="text-decoration: none">Forum</span></font></a></font></b></td>
</tr>
<tr>
<td height="22" align="left">
<font size="2"> <img border="0" src="images/<?php echo $theme; ?>/fleche.gif"> </font>
<font size="2" color="#0F3A7F">
<b>
<a href="?action=Chat">
<font color="#0F3A7F">
<span style="text-decoration: none">Chat</span></font></a></b></font></td>
</tr>
<tr>
<td height="22" align="left">
<font size="2"> <img border="0" src="images/<?php echo $theme; ?>/fleche.gif"> </font>
<font size="2" color="#0F3A7F">
<b>
<a href="?action=Inscription">
<font color="#0F3A7F">
<span style="text-decoration: none">Inscription</span></font></a></b></font></td>
</tr>
<tr>
<td height="22" align="left">
<font size="2"> <img border="0" src="images/<?php echo $theme; ?>/fleche.gif"> </font>
<font size="2" color="#0F3A7F">
<b>
<a href="?action=Administration">
<font color="#0F3A7F">
<span style="text-decoration: none">Administration</span></font></a></b></font>
</td>
</tr>
</table>
<br />
<table border="1" style="border-collapse: collapse" width="100%" id="table12" bordercolor="#BDD1EC" height="42">
<tr>
<td background="images/<?php echo $theme; ?>/top.jpg" height="21">
<p align="center">
<font size="2" color="#0F3A7F"><b>Menu</b></font></p>
</td>
</tr>
<?php
// ON SELECTIONNE LES PAGES CREEES
$sql = "SELECT * FROM table_lot";
$req = mysql_query($sql) or die('error !');
while($data = mysql_fetch_array($req))
{
?>
<tr>
<td height="22" onMouseOut="javascript:this.style.background=''" onMouseOver="javascript:this.style.background='<?php echo $backcolor; ?>'" background="">
<font size="2"> <img border="0" src="images/<?php echo $theme; ?>/fleche.gif"> <a style="text-decoration:none" href="?action=lot&id_lot=<?php echo $data['id_lot']; ?>&titrep=<?php echo $data['titre']; ?>"><?php echo $data['titre']; ?></a></font>
</td>
</tr>
<?php
}
?>
</table>
<table border="1" style="border-collapse: collapse" width="100%" id="table10" bordercolor="#BDD1EC" height="42">
<tr>
<td background="images/<?php echo $theme; ?>/top.jpg" height="21">
<p align="center">
<font size="2" color="#0F3A7F"><b>Membre</b></font></p>
</td>
</tr>
<tr>
<form method="POST" action="?ident=1">
<td height="22">
<?php
// SI L'UTILISATEUR EST CONNECTE ON AFFICHE UN MESSAGE SINON ON AFFICHE LE FORMULAIRE DE CONNEXION
if($connec==1)
{
echo "<br /><p align=\"center\"><font size=\"2\">Vous êtes identifiez en tant que ".$prenom." ".$nom."<br /><br /><a href=\"?desident=1\">Se déconnecter</a></font></p><br />";
}
else
{
?>
<table border="0" style="border-collapse: collapse" width="98%" id="table11">
<tr>
<td>
<p align="right">
<font size="2">
E-mail : </font>
</p>
</td>
<td>
<input type="text" name="email" size="9" />
</td>
</tr>
<tr>
<td>
<p align="right">
<font size="2"> MDP : </font>
</p>
</td>
<td>
<input type="password" name="mdp" size="9" />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="Envoyer" name="B1" style="float: left" />
</td>
</tr>
</table>
<?php } ?>
</td>
</form>
</tr>
</table>
</td>
<td width="80%" height="90" valign="top">
<table align="right" border="1" style="border-collapse: collapse" width="98%" id="table5" bordercolor="#BDD1EC" height="73">
<tr>
<td background="images/<?php echo $theme; ?>/top.jpg">
<p align="center">
<font size="2" color="#0F3A7F"><b>
<?php
// SI LA VARIABLE ACTION EST EXISTANTE ON L'AFFICHE SINON ON AFFICHE LE TITRE DE LA PREMIERE PAGE CREEE
if(isset($action))
{
if($action=="page")
{
echo $titrep;
}
else
{
echo $action;
}
}
else
{
$sql = "SELECT * FROM table_pages ORDER BY id_page ASC LIMIT 1";
$req = mysql_query($sql) or die('error !');
$data = mysql_fetch_array($req);
echo $data['titre'];
}
?>
</b></font>
</p>
</td>
</tr>
<tr>
<td height="51">
<br />
<table align="center" border="0" style="border-collapse: collapse" width="94%" id="table6">
<tr>
<td>
<font size="2">
<?php
// SI LA VARIABLE ACTION EST EXISTANTE ON AFFICHE LA PAGE LUI ETANT ASSOCIEE SINON ON AFFICHE LA PREMIERE PAGE CREEE
if(isset($action))
{
include $action.".php";
}
else
{
$sql = "SELECT * FROM table_pages ORDER BY id_page ASC LIMIT 1";
$req = mysql_query($sql) or die('error !');
$data = mysql_fetch_array($req);
echo nl2br($data['contenu']);
echo "<p align=\"right\">Article ajouté le ".$data['date']."</p>";
}
?>
</font>
</td>
</tr>
</table>
<br />
</td>
</tr>
</table>
</td>
<td width="1%" height="90"> </td>
</tr>
<tr>
<td width="100%" colspan="4" background="images/<?php echo $theme; ?>/botom.jpg" valign="bottom">
<p align="center">
<b><font size="1" color="#0F3A7F"><br /><A HREF="http://www.hauts-de-seine.net/" style="text-decoration:none"onMouseOver="window.status='Cliquer icipour allez sue HDS.net';
return true">http://www.hauts-de-seine.net/</A>|</font></b>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
<noscript> |
2) dans mon body
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
| <?php
if($valide!=1)
{
?>
<script language="JavaScript">
<!-- // create calendar object(s) just after form tag closed
// specify form element as the only parameter (document.forms['formname'].elements['inputname']);
// note: you can have as many calendar objects as you need for your application
var cal3 = new calendar1(document.forms['lot_tma'].elements['date_deb_mer']);
cal3.year_scroll = true;
cal3.time_comp = true;
//-->
</script>
<form align="center" method="POST" action="?action=Ajout_lot_tma&valide=1">
<table border="0" style="border-collapse: collapse" width="38%" id="table1">
<tr>
<td width="101" valign="top" align="right">
<font size="2">Titre : </font>
</td>
<td>
<input type="text" name="titre" size="10" />
</td>
</tr>
<tr>
<td width="101" valign="top" align="right">
<font size="2">Type : </font>
</td>
<td>
<select name="type" />
<option value="1">Evolutif
<option value="2">Correctif
</select>
</td>
</tr>
<tr>
<td width="101" valign="top" align="right">
<font size="2">Statut : </font>
</td>
<td>
<select name="statut" />
<option value="1">En recette</option>
<option value="2">En production</option>
<option value="3">En attente</option>
<option value="4">En cours</option>
</td>
</tr>
<form name="lot_tma">
<tr>
<td width="101" valign="top" align="right">Choisir date/heure (j-mois-années-heure)<br>
<a href="javascript:cal3.popup();"><img src="../portail/images/cal.gif" width="16" height="16" border="0" alt="Cliquez ici pour obtenir la date.">
<input type="Text" name="date_deb_mer" value="" size="20">
</a><br>
</td>
</tr>
<tr>
<?php
// requête SQL qui compte le nombre total d'enregistrement dans la table et qui
//récupère tous les enregistrements
$select = 'SELECT nom_user,prenom_user,poste_user, secteur_user,email_user FROM tables_membres_dsi';
$result = mysql_query($select,$base) or die ('Erreur : '.mysql_error() );
$total = mysql_num_rows($result);
// si on a récupéré un résultat on l'affiche.
if($total) {
// debut du tableau
echo '<table bgcolor="#FFFFFF">'."\n";
// première ligne on affiche les titres prénom et surnom dans 2 colonnes
echo '<tr>';
echo '<td bgcolor="#669999"><b><u>Nom</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Prénom</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Poste</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Secteur</u></b></td>';
echo '<td bgcolor="#669999"><b><u>E-mail</u></b></td>' ;
echo '</tr>'."\n";
// lecture et affichage des résultats sur 2 colonnes, 1 résultat par ligne.
while($row = mysql_fetch_array($result)) {
//un teste à enlevé ....
// jusqu'a ici.....
echo '<tr>';
echo '<td bgcolor="#CCCCCC">'.$row["nom_user"].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row["prenom_user"].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row["poste_user"].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row["secteur_user"].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row["email_user"].'</td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
// fin du tableau.
}
else echo 'Pas d\'enregistrements dans cette table...';
// on libère le résultat
mysql_free_result($result);
?>
</tr>
</table>
</form>
<?php
}
else
{
if(isset($_POST['statut']) AND isset($_POST['titre']))
{
if($_POST['statut']!=NULL AND $_POST['titre']!=NULL)
{
// ON LE PAGE DANS LA TABLE
$sql = "INSERT INTO table_lot(titre,type,statut,date_deb_mer,date_fin_mer,date_mep,liste_tickets,liste_users) VALUES('$titre','$type','$statut','$date_deb_mer$')";
mysql_query($sql) or die('Erreur SQL !'.$sql.' '.mysql_error());
echo "Votre lot a bien été enregistré !<br /><a href=\"?action=Administration\">Cliquez ici</a> pour retourner à l'administration.";
}
}
}
?> |
3) puis j'ai crée le calender.html en changer le path !
Est ce qqun pourrait me dire si je suis bien le tutos ?