IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Date du jour en rouge dans mon calendrier


Sujet :

JavaScript

  1. #1
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 60
    Points : 40
    Points
    40
    Par défaut Date du jour en rouge dans mon calendrier
    Bonjour à tous,
    j'ai un calendrier qui fonctionne trés bien en javascript et css mais il lui manque juste une chose que j'aimerais améliorer, c'est de pourvoir avoir la date du jour en rouge au demarrage du calendrier mais je n'y arrive pas. Je suis pas assez pechu en javasript pour cà.
    Pourriez-vous me donner un coup de main?
    Voulez mes deux codes
    calendrier css
    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
    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
     
    /* jours pour Netscape */
    .NSday
    {
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	bold;
    	font-size:	12px;
    	color:		#0000cc;
    	text-decoration: none;
    }
    /* tableau des jours */
    .Gtab
    {
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	normal;
    	font-size:	12px;
    	text-decoration: none;
    	border:	solid 1px #000000;
    	background:	#6699FF;
    	width:		152px;
    }
    /* champs texte */
    .Gname
    {
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	bold;
    	font-size:	12px;
    	color:		#ffffff;
    	text-decoration: none;
    }
     
    /* champs texte */
    .Gtxt
    {
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	normal;
    	font-size:	12px;
    	color:		#6c628a;
    	text-decoration: none;
    	margin-left:	0px;
    }
    /* en-tete semaine */
    .Gh1, .Gh2, .Gh3, .Gh4, .Gh5
    {
    	width: 		20px;
    	height: 	16px;
    	font-size:	12px;
    	background:	#6699FF;
    	border:		solid 1px #6699FF;
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	bold;
    	color:		#ffffff;
    	text-align:	center;
    	line-height:	16px;
    }
    .Gh0, .Gh6
    {
    	width: 		20px;
    	font-size:	12px;
    	height: 	16px;
    	border:		solid 1px #b9c0d9;
    	background:	#b9c0d9;
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	bold;
    	color:		#ffffff;
    	text-align:	center;
    	line-height:	16px;
    }
    .Gfree
    {
    	width: 		20px;
    	height: 	16px;
    	background:	#6699FF;
    	border:		solid 1px #ffffff;
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	normal;
    	padding:	0px;
    	margin:		0px;
    	color:		#000000;
    	text-align:	center;
    	cursor: 	pointer;
    	line-height:	16px;
    }
    .Gfreeon
    {
    	width: 		20px;
    	height: 	16px;
    	background:	#b9c0d9;
    	border:		solid 1px #000000;
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	normal;
    	padding:	0px;
    	margin:		0px;
    	color:		#000000;
    	text-align:	center;
    	cursor: 	pointer;
    	line-height:	16px;
    }
    .Gc1, .Gc2, .Gc3, .Gc4, .Gc5
    {
    	width: 		20px;
    	height: 	16px;
    	background:	#6699FF;
    	border:		solid 1px #6699FF;
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	normal;
    	padding:	0px;
    	margin:		0px;
    	color:		#000000;
    	text-align:	center;
    	cursor: 	default;
    	line-height:	16px;
    }
    .Gc1on, .Gc2on, .Gc3on, .Gc4on, .Gc5on
    {
    	width: 		20px;
    	height: 	16px;
    	background:	#6699FF;
    	border:		solid 1px #ffffff;
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	normal;
    	padding:	0px;
    	margin:		0px;
    	color:		#ffffff;	
    	text-align:	center;
    	cursor: 	pointer;
    	line-height:	16px;
    }
    .Gc0, .Gc6
    {
    	width: 		20px;
    	height: 	16px;
    	border:		solid 1px #b9c0d9;
    	background:	#b9c0d9;
    	font-family: 	Arial, Helvetica, sans-serif;
    	font-weight: 	normal;
    	padding:	0px;
    	margin:		0px;
    	color:		#000000;
    	text-align:	center;
    	cursor: 	default;
    	line-height:	16px;
    }
    .Gc0on, .Gc6on
    {
    	width: 		20px;
    	height: 	16px;
    	border:		solid 1px #ffffff;
    	background:	#b9c0d9;
    	font-family: 	Arial, Helvetica, sans-serif;
    	font-weight: 	normal;
    	padding:	0px;
    	margin:		0px;
    	color:		#ffffff;
    	text-align:	center;
    	cursor: 	pointer;
    	line-height:	16px;
    }
    et le calendrier.js

    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
    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
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
     
    function calendrier(n, min, max)
    {
    	this.target= null;
    	this.name =  new String(n);
    	this.tag =  new String();
    	this.title =  new String("");
    	this.date=new Date();
    	this.moving = new Boolean(false);
    	this.vis = new Boolean(false);
    	this.free = new Boolean(false);
    	this.curYear = new Number(this.date.getFullYear());
    	this.maxYear = new Number(this.curYear+max);
    	this.minYear = new Number(this.curYear-min);
    	this.curMonth= new Number(this.date.getMonth());
    /*
    * calendrier.setFree(Boolean vis)
    * affiche ou non des jours feries
    */
    	this.setFree=function(vis)
    	{
    		this.free=vis;
    		if(this.vis==true)
    			this.show();
    		return;
    	}
    /*
    * calendrier.IsDragable(Boolean drag)
    * active/desactive l'option drag&drop 
    */
    	this.isDragable=function(drag)
    	{
    		if(drag==true && !document.layers)
    		{
    			document.onmousemove=this.getMouse;
    			document.getElementById(this.div).root=this;
    			document.getElementById(this.div).onmousedown=this.startMove;
    			document.getElementById(this.div).onmouseup=this.endMove;
    		}
    		return;
    	}
    /*
    * calendrier.startMove()
    * initialise le drag & drop
    */
    	this.startMove=function(evt)
    	{
    		var event;
    		var tmp;
    		if(this.root.vis!=true)
    			return;
    		if(document.all)
    		{
    			event = window.event;
    			tmp = event.srcElement;
    			if(!tmp.form)
    			{
    				this.root.fixX = tmp.offsetLeft+event.offsetX;
    				this.root.fixY = event.offsetY;
    				while(tmp.parentElement!=document.getElementById(this.root.div) && tmp.parentElement!=null )
    				{
    					this.root.fixX += tmp.parentElement.offsetLeft;
    					this.root.fixY += tmp.parentElement.offsetTop;
    					tmp = tmp.parentElement;
    				}
    				this.root.moving=true;
    				self.movingCalendar = this.root;
    			}
    		}
    		else
    		{
    			event = evt;
    			tmp = event.target;
    			if( !tmp.form && tmp.tagName!="SELECT" && tmp.tagName!="OPTION" && tmp.tagName!="scrollbar" )
    			{			
    				this.root.fixX = event.layerX;
    				this.root.fixY = event.layerY;
    				this.root.moving=true;
    				self.movingCalendar = this.root;
    			}
    		}
    		return evt;
    	}
    /*
    * calendrier.endMove()
    * termine le drag & drop
    */
    	this.endMove=function()
    	{
    		if(self.movingCalendar!=null)
    		{
    			self.movingCalendar.moving=false;
    		}
    		return false;
    	}
    /*
    * calendrier.getMouse(Event evt)
    * change la liste des jours feriés jours feries
    */
    	this.getMouse=function(evt)
    	{
     
    		var event;
    		if(document.all)
    		{
    			event = window.event;
    			var scrollObj = (document.documentElement) ? document.documentElement : document.body;
    			this.posX = self.event.clientX+scrollObj.scrollLeft;
    			this.posY = self.event.clientY+scrollObj.scrollTop;
    		}
    		else
    		{
    			event = evt;
    			this.posX = evt.pageX ;
    			this.posY = evt.pageY ;
    		}
    		if(self.movingCalendar!=null)
    		{
    			if(self.movingCalendar.moving==true && self.movingCalendar.vis==true )
    				self.movingCalendar.move(this.posY-self.movingCalendar.fixY, this.posX-self.movingCalendar.fixX);
    		}
    		return false;
    	}
    /*
    * calendrier.move(Number x, Number y)
    * déplace le calendrier
    */
    	this.move=function(x, y)
    	{
    		if(!document.layers)
    		{
    			document.getElementById(this.div).style.top = x+"px";
    			document.getElementById(this.div).style.left = y+"px";
    		}
    		return false;
    	}
     
    /*
    * calendrier.setFreeDay(Array fd)
    * change la liste des jours feriés jours feries
    */
    	this.setFreeDay=function(fd)
    	{
    		this.freeday.length=0;
    		for(var i=0; i<fd.length; i++)
    			this.freeday[i] = new String(fd[i]);
    		if(this.vis==true)
    			this.show();
    		return;
    	}
    /*
    * calendrier.isFreeDay(d,m)
    * true si jour ferié
    */
    	this.isFreeDay=function(d,m)
    	{
    		var tmp = this.checkDate(d)+"-"+this.checkDate(parseInt(m)+1);
    		if(this.free==false)
    			return false;
    		for(var i=0; i<this.freeday.length; i++)
    			if( tmp == this.freeday[i])
    				return true;
    		return false;
    	}
    /*
    * calendrier.setTitle(t)
    * change le titre du calendrier
    */
    	this.setTitle=function(t)
    	{
    		this.title = t;
    		if(this.vis==true)
    			this.show();
    		return;
    	}
    /*
    * calendrier.mList()
    * retourne la liste des mois 
    */
    	this.mList=function()
    	{
    		var tmp = "<table border='0' cellpadding='0' cellspacing='0' class='Gtab'>";
     
    		tmp += "<tr><td align='center' colspan='2' class='Gname'>";
    		if(document.layers)
    		{
    			tmp += "<table width='100%'>";
    			tmp += "<tr>";
    			tmp += "<td class='Gname' align='center'>"+this.title+"</td>";
    			tmp += "<td><a href='javascript://' onclick='"+this.name+".hide();' class='Gname'>X</a></td>";
    			tmp += "</tr>";
    			tmp += "</table>";
    		}
    		else
    		{
    			tmp += "<span style='float:left; text-indent:20px;'>"+this.title+"</span>";
    			tmp += "<span style='float:right;'>";
    			tmp += "<a href='javascript://' onclick='"+this.name+".hide();' class='Gname'>X</a>";
    			tmp += "</span>";
    		}
    		tmp += "</td></tr>";
    		tmp += "<tr>";
    		tmp += "<td class='Gtxt'><select name='"+this.name+"month' class='Gtxt' ";
    		tmp += "onchange='"+this.name+".setMonth(this[this.selectedIndex].value)' >\n";
    		for(var i=0; i<this.month.length; i++)
    		{			
    			tmp += "<option value='"+i+"'";
    			if(this.curMonth==i)
    				tmp += " selected";
    			tmp += ">"+ this.month[i] +"</option>\n";
    		}
    		tmp += "</select></td><td class='Gtxt'>\n";
    		tmp += this.yList();
    		tmp += "</td></tr></table>";
    		tmp += this.dList();
    		return tmp;
    	}
    /*
    * calendrier.yList()
    * retourne la liste des années 
    */
    	this.yList=function()
    	{
    		var tmp = "<select name='"+this.name+"year' class='Gtxt' ";
    		tmp += "onchange='"+this.name+".setYear(this[this.selectedIndex].value);' >\n";
    		for(var i=this.minYear; i<=this.maxYear; i+=1)
    		{
    			tmp += "<option value='"+i+"'";
    			if(this.curYear==i)
    				tmp += " selected";
    			tmp += ">"+ i +"</option>\n";
    		}
    		tmp += "</select>\n";
    		return tmp;
    	}
     
    	this.dayCell=function(d,n)
    	{
    		var tmp = new String("");
    		if(this.isFreeDay(d,this.curMonth))
    			tmp += "<td class='Gfree'";
    		else
    			tmp += "<td class='Gc"+n+"'";
    		if(!document.layers)
    		{
    			tmp += "title='"+this.checkDate(d)+" "+this.month[this.curMonth]+" "+this.curYear+"'";
    			tmp += " onmousedown='"+this.name+".getDate(\"";
    			tmp += this.checkDate(d)+"-";
    			tmp += this.checkDate(1+parseInt(this.curMonth))+"-";
    			tmp += this.curYear+"\"";
    			tmp += ");' "; 
    			tmp += " onmouseover='this.className=this.className+\"on\";' ";
    			tmp += " onmouseout='this.className= this.className.substring(0,this.className.indexOf(\"on\"));'";
    		}
    		else
    			tmp += " width='22' height='16' ";
    		tmp += ">";
    		return tmp;
    	}
    /*
    * calendrier.dList()
    * retourne le tableau des jours
    */
    	this.dList=function()
    	{
    		var cur=new Number(1);
    		var tmpDate = new Date();
    		var tmp = new String("<table border='0' cellpadding='0' cellspacing='0' class='Gtab'>");
    		tmpDate.setDate(cur);
    		tmpDate.setMonth(this.curMonth);
    		tmpDate.setFullYear(this.curYear);
    		tmp += "<tr>\n";
    		for(var i=1; i<this.day.length; i++)
    			tmp += "<td class='Gh"+i+"'>"+ this.day[i] +"</td>\n";
    		tmp += "<td class='Gh0'>"+ this.day[0] +"</td>\n";
    		tmp += "</tr>\n";
    		for(var j=0; j<6; j++)
    		{
    			tmp += "<tr>\n";
    			for(var i=1; i<this.day.length; i++)
    			{
    				tmpDate.setDate(cur);			
    				if( cur<=31 && i==tmpDate.getDay() && this.curMonth==tmpDate.getMonth())
    				{
    					tmp += this.dayCell(cur,i);
    					tmp += this.getLink(cur);
    					cur+=1;
    				}
    				else
    				{
    					tmp += "<td class='Gc"+i+"'";
    					tmp += ">&nbsp;";
    				}
    				tmp += "</td>\n";
    				tmpDate.setDate(cur);
    			}
    			if( cur==tmpDate.getDate() && this.curMonth==tmpDate.getMonth())
    			{
    				tmp += this.dayCell(cur,0);
    				tmp += this.getLink(cur);
    				cur+=1;
    			}
    			else
    			{
    				tmp += "<td class='Gc0'";
    				tmp += ">&nbsp;";
    			}
    			tmp += "</td>\n</tr>\n";
    		}
    		tmp += "</table>\n";
    		return tmp;
    	}
    /*
    * calendrier.getLink(c)
    * retourne la balise d'un lien
    */
    	this.getLink = function(c)
    	{
    		var tmp = new String("");
    		if(document.layers)
    		{
    			tmp = "<a href='javascript://' ";
    			tmp += "onclick='"+this.name+".getDate(\""; 
    			tmp += this.checkDate(d)+"-";
    			tmp += this.checkDate(1+parseInt(this.curMonth))+"-";
    			tmp += this.curYear+"\"";
    			tmp += ");' class='NSday'>"+(c)+"</a>";
     
    		}
    		else
    		{
    			tmp = (c);
    		}
    		return tmp;
    	}
    /*
    * calendrier.setMonth( Integer m )
    * modifie le mois à afficher
    */
    	this.setMonth = function(m)
    	{
    		this.curMonth = m;
    		this.show();
    		return;
    	}
    /*
    * calendrier.getYear( Integer y )
    * modifie l'année à afficher
    */
    	this.getYear = function (y)
    	{
    		if(document.layers)
    		{
    			for(var i=0; i<document.layers[this.div].document.forms[this.name+"_form"][this.name+"year"].length; i++)
    			{
    				if(document.layers[this.div].document.forms[this.name+"_form"][this.name+"year"][i].value==y)
    				{
    					document.layers[this.div].document.forms[this.name+"_form"][this.name+"year"].selectedIndex=i;
    					this.setYear(y);
    					return;
    				}
    			}
    		}
    		else
    		{
    			for(var i=0; i<document.forms[this.name+"_form"].elements[this.name+"year"].length; i++)
    			{
    				if(document.forms[this.name+"_form"].elements[this.name+"year"][i].value==y)
    				{
    					document.forms[this.name+"_form"].elements[this.name+"year"].selectedIndex=i;
    					this.setYear(y);
    					return;
    				}
    			}
    		}
    		return;
    	}
    /*
    * calendrier.getMonth( Integer m )
    * modifie le mois à afficher
    */
    	this.getMonth = function (d)
    	{
    		if(document.layers)
    		{
    			for(var i=0; i<document.layers[this.div].document.forms[this.name+"_form"][this.name+"month"].length; i++)
    			{
    				if(document.layers[this.div].document.forms[this.name+"_form"][this.name+"month"][i].value==d)
    				{
    					document.layers[this.div].document.forms[this.name+"_form"][this.name+"month"].selectedIndex=i;
    					this.setMonth(d);
    					return;
    				}
    			}
    		}
    		else
    		{
    			for(var i=0; i<document.forms[this.name+"_form"].elements[this.name+"month"].length; i++)
    			{
    				if(document.forms[this.name+"_form"].elements[this.name+"month"][i].value==d)
    				{
    					document.forms[this.name+"_form"].elements[this.name+"month"].selectedIndex=i;
    					this.setMonth(d);
    					return;
    				}
    			}
    		}
    		return;
    	}
    /*
    * calendrier.setYear( Integer y )
    * modifie l'année à afficher
    */
    	this.setYear = function (y)
    	{
    		this.curYear = y;
    		this.show();
    		return;
    	}
    /*
    * calendrier.setTarget( Object obj )
    * change le champs cible d'affichage de la date
    * BUG OPERA!
    */
    	this.setTarget = function (obj)
    	{
    		this.target = obj;
    		return;
    	}
    /*
    * calendrier.hide()
    * masque le calendrier
    */
    	this.hide = function()
    	{
    		if(document.layers)
    			document.layers[this.div].visibility='hide';
    		else
    		{
    			document.getElementById(this.div).style.visibility = 'hidden';
    			document.getElementById(this.div).style.display = 'none';
    		}
    		this.vis = false;
    		this.endMove();
    		return;
    	}
     
    /*
    * calendrier.getDate()
    * retourne la date selectionnée dans le champs cible
    */
    	this.getDate = function(d)
    	{
    		if(this.target!=null)
    		{
    			this.target.value=d;	
    			this.hide();
    		}
    		return;
    	}
     
    /*
    * calendrier.show()
    * affiche le calendrier
    */
    	this.show = function()
    	{
    		this.vis = true;
    		this.tag = "<form name='"+this.name+"_form' method='post'>\n";
    		this.tag += this.mList();
    		this.tag += "</form>\n";
    		if(document.layers)
    		{
    			with(document.layers[this.div])
    			{				
    				document.open("text/html");
    				document.write(this.tag);
    				document.close();
    				visibility='show';
    			}
    		}
    		else
    		{
    			document.getElementById(this.div).innerHTML = ""+this.tag;
    			document.getElementById(this.div).style.visibility = 'visible';
    			document.getElementById(this.div).style.display = 'block';
    		}
    		return;
    	}
    /*
    * calendrier.init( String d )
    * initialise le Calendrier à la date actuelle
    * paramêtres : 
    * d : nom du calque d'affichage
    * obj : objet dont la propriété value va recevoir le String de la date
    */
    	this.init = function(d, obj)
    	{
    		this.div=d;
    		this.target = obj;
    		this.date=new Date();
    		this.date.setDate(1);		
    		this.curMonth = this.date.getMonth();
    		this.curYear = this.date.getFullYear();
    		if(!self.movingCalendar)
    			self.movingCalendar=null;
    		return;
    	}
    /*
    * calendrier.checkDate( Integer d )
    * paramêtre : le jour d'une date
    */
    	this.checkDate = function(d)
    	{
    		if(parseInt(d)<=9)
    			return "0"+parseInt(d);
    		return parseInt(d);
    	}
    	return this;
    }
    /******************************/
    calendrier.prototype.day = ["D", "L", "M", "M", "J", "V", "S" ];
    calendrier.prototype.month = ["Janvier", 
    				"F&eacute;vrier", 
    				"Mars", 
    				"Avril", 
    				"Mai", 
    				"Juin", 
    				"Juillet", 
    				"Ao&ucirc;t", 
    				"Septembre", 
    				"Octobre", 
    				"Novembre", 
    				"D&eacute;cembre"];
    /* jours feriés français */
    calendrier.prototype.freeday= ["01/01","01/05","08/05","14/07","15/08","01/11","11/11","25/12"];
    /******************************/
    Merci d'avance et bon courage à tous

  2. #2
    Expert confirmé
    Avatar de le_chomeur
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2006
    Messages
    3 653
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 3 653
    Points : 4 835
    Points
    4 835
    Par défaut
    Salut , tu aurais pus donner un exemple de l'implémentation de ton calendrier
    Bon sinon voila la solution pour mettre en exergue la date courante :

    sur ta fonction "this.dayCell /******/"

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    this.dayCell=function(d,n)
    	{
    		var date = new Date(); //récupération de la date du jour courant
     
    		var tmp = new String("");
    		if(this.isFreeDay(d,this.curMonth))
    			tmp += "<td class='Gfree'";
    		else if(d == date.getDate()) //vérification du jour courant par rapport a la construction de ton tableau
    			tmp += "<td class='dateDuJour'"; //Affectation de la nouvelle classe
    		else
    			tmp += "<td class='Gc"+n+"'";
    /*******/
    Coté css :

    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
     
     
     .dateDuJour{
    	width: 		20px;
    	height: 	16px;
    	background:	yellow;
    	border:		solid 1px red;
    	font-family: 	Arial,Helvetica,sans-serif;
    	font-weight: 	normal;
    	padding:	0px;
    	margin:		0px;
    	color:		#000000;
    	text-align:	center;
    	cursor: 	default;
    	line-height:	16px;
     }
    ps : j'ai voulu utiliser la propriété this.date qui est implémenté dans la classe calendrier mais elle me renvoit 1 et je n'ai pas le temps de chercher plus voila pourquoi je recréer la date avant la vérif


    Coordialement
    est ton ami fait gagner du temps à ceux qui aident , donc un message avec la balise résolu laisse plus de temps pour résoudre d'autres problèmes

    Premier ministre du CCMPTP (Comité Contre le Mot "Problème" dans les Titres de Posts )

  3. #3
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 60
    Points : 40
    Points
    40
    Par défaut merci
    Merci ca marche presque nickel
    En fait, pour le mois en cours, il affiche bien la date en jaune par contre il me l'affiche aussi sur tous les autres mois.
    Par exemple si on est le 10 et bien il affiche tous les 10 en jaune quelque soit le mois
    J'ai essayé
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    	else if(d == date.getDate(this.curMonth))
    mais ca ne fonctionne pas. Tu as une idée?
    Merci encore

  4. #4
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 60
    Points : 40
    Points
    40
    Par défaut En fait ca marche pas
    Je me suis vite emballé car en fait le bout de script que tu m'as donné a marché pour samedi mais dimanche et ce matin lundi, ca ne marche plus. Mon calendrier ne veux plus s'afficher du tout. Il s'affiche que lorsque je mets ton code en commentaire.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    else if(d == date.getDate()) //vérification du jour courant par rapport a la construction de ton tableau
    			tmp += "<td class='dateDuJour'"; //Affectation de la nouvelle classe
    Je comprends plus rien.
    J'ai essayé plusieurs facons mais rien n'y fait, aucun affichage de calendrier.
    C'est comme si il y avait un conflit de code
    Merci d'avance

  5. #5
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 60
    Points : 40
    Points
    40
    Par défaut Information supplémentaire
    En fait, lorsque je laisse le code.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    this.dayCell=function(d,n)
    	{
    		var date = new Date(); //récupération de la date du jour courant
     
    		var tmp = new String("");
    		if(this.isFreeDay(d,this.curMonth))
    			tmp += "<td class='Gfree'";
    		else if(d == date.getDate()) //vérification du jour courant par rapport a la construction de ton tableau
    			tmp += "<td class='dateDuJour'"; //Affectation de la nouvelle classe
    		else
    			tmp += "<td class='Gc"+n+"'";
    /*******/
    Ca ne marche pas du tout par contre quand je le met en commentaire ca marche super

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    this.dayCell=function(d,n)
    	{
    		var tmp = new String("");
    		if(this.isFreeDay(d,this.curMonth))
    			{tmp += "<td class='Gfree'";}
    		//else if(d == date.getDate()) //vérification du jour courant par rapport a la construction de ton tableau
    		//	tmp += "<td class='dateDuJour'"; //Affectation de la nouvelle classe
    		else
    			{tmp += "<td class='Gc"+n+"'";}
    Pourquoi mon d==date.getDate() ne fonctionne pas?
    A n'y rien comprendre
    Merci de votre aide

  6. #6
    Expert confirmé
    Avatar de le_chomeur
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2006
    Messages
    3 653
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 3 653
    Points : 4 835
    Points
    4 835
    Par défaut
    je n'arrive pas a trouver pkoi cela bug :-/ sur le :

    j'ai essayé en renommant date en autre chose, même problème ...

    Par contre j'ai trouvé pourquoi en changeant de mois on se retrouve avec le jour courant en jaune ...

    car tu utilises : this.year et this.month a l'initialisation , mais également lors du changement de date/année donc, on garde toujours la date courante comme date sélectionné il faudrait que tu instancies 2 nouvelles date permettant de définir la date courante, et 2 autre qui te servirais a sélectionner une date.

    Pour l'autre bug je cherche encore
    est ton ami fait gagner du temps à ceux qui aident , donc un message avec la balise résolu laisse plus de temps pour résoudre d'autres problèmes

    Premier ministre du CCMPTP (Comité Contre le Mot "Problème" dans les Titres de Posts )

  7. #7
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 60
    Points : 40
    Points
    40
    Par défaut merci
    Merci pour ta reponsse mais je suis assez limité en javascript et je comprends pas ce qu'il faut que je fasse quand tu dis "il faudrait que tu instancies 2 nouvelles date permettant de définir la date courante, et 2 autre qui te servirais a sélectionner une date."
    Et merci pour ta recherche sur le reste
    c'est tres sympa

  8. #8
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 60
    Points : 40
    Points
    40
    Par défaut presque résolu ;-)
    Bonjour à tous et surtout merci à toi Le_chomeur
    J'ai graté un peu par rapport à ce que tu m'as dit et tu avais raison, il fallait une autre instance de date et j'ai presque resolu mon probleme en entier
    voilà ce que j'ai fait
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    var tmp = new String("");
    		var datedujour=new Date();
    		if(this.isFreeDay(d,this.curMonth))
    			{tmp += "<td class='Gfree'";}
    		else if(d == datedujour.getDate() && this.curMonth == datedujour.getMonth()) //vérification du jour courant par rapport a la construction de ton tableau
    			tmp += "<td class='dateDuJour'"; //Affectation de la nouvelle classe
    		else
    			{tmp += "<td class='Gc"+n+"'";}
    J'ai bien mon jour en jaune uniquement sur le mois en cours par contre quand je change l'année j'ai toujours mon jour en jaune (un moindre mal)
    j'ai essayé cà mais ca marche pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    var tmp = new String("");
    		var datedujour=new Date();
    		if(this.isFreeDay(d,this.curMonth))
    			{tmp += "<td class='Gfree'";}
    		else if(d == datedujour.getDate() && this.curMonth == datedujour.getMonth() && this.curYear == datedujour.getYear()) //vérification du jour courant par rapport a la construction de ton tableau
    			tmp += "<td class='dateDuJour'"; //Affectation de la nouvelle classe
    		else
    			{tmp += "<td class='Gc"+n+"'";}
    Si tu as une idée
    En tout cas merci de ton aide

  9. #9
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 60
    Points : 40
    Points
    40
    Par défaut Voilà enfin la reponse....
    Apres pas mal de recherche avec mon petit niveau, voila la solution à mon probleme.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    var tmp = new String("");
    		var datedujour=new Date();
    		if(this.isFreeDay(d,this.curMonth))
    			{tmp += "<td class='Gfree'";}
    		else if(d == datedujour.getDate() && this.curMonth == datedujour.getMonth() && this.curYear == datedujour.getFullYear()) //vérification du jour courant par rapport a la construction de ton tableau
    			tmp += "<td class='dateDuJour'"; //Affectation de la nouvelle classe
    		else
    			{tmp += "<td class='Gc"+n+"'";}
    Grand merci à Le_chomeur de m'avoir aider dans cette lourde tache.
    Bon courage à tous

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de date: Inversion jour et mois dans cellule de résultat
    Par tic59 dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 04/11/2010, 21h04
  2. Recuperer la date d'une celule colorisée dans un calendrier
    Par Mielure dans le forum Macros et VBA Excel
    Réponses: 11
    Dernier message: 01/07/2008, 15h08
  3. Réponses: 2
    Dernier message: 26/12/2006, 12h49
  4. date pdu jour par défaut dans create table
    Par r83 dans le forum SQL Procédural
    Réponses: 1
    Dernier message: 20/10/2006, 22h45
  5. Mise à jour du texte dans mon scrolltaux.fla
    Par icewolf dans le forum Flash
    Réponses: 2
    Dernier message: 28/12/2005, 09h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo