Je m'explique:
j'ai 2 calendriers qui lorsque l'on clique sur 1 jour,1 mois ou 1 année réactualise ma page pour ce placer sur la bonne date.
Jusque là pas de problême car je peux afficher la date que je veux mais là ça coince c'est lorsque je sélectionne la date du 2 eme tableau, il nme réactualise aussi le premier qui se remet sur la date du jour. et moi je voudrai récupérer la variable $datedébut(le 1er calendrier) avant réactualisation!!!
le prog est 1 mélange de php et de javascript et comme je suis mauvais et novice dans les 2 j'appelle au secours!!
voici mon code qui est tès long désolé
?>
<a name="debut"></a>
<center>
<h2><br>
<em><b>
<u>choisissez vos dates de recherche</u>
</em>
</h2><br>
(1 journée de travail vaut 8 heures)</b>
<table width="720" border="2" bordercolor="#48465F" bgcolor="C1CEF9">
<tr>
<td width="124" height="46" style="padding-left:4; padding-right:4; padding-top:1; padding-bottom:1">
<center>
<b>date début </b></td>
<td width="219" bgcolor="#E5E6E9" style="border-right-style:solid; border-right-width:3">
<?
// Section de configuration
$bgcolor="FBFBFB" ; // Couleur de fond
$daybgcolor="4B73F8" ; // Couleur des jours de la semaine
$dombgcolor="C1CEF9" ; // Couleur du jour sélectionné
$dayholcolor="98EAF6" ; // Couleur des WE
// Mois
$month[0] = "Janvier" ;
$month[1] = "Février" ;
$month[2] = "Mars" ;
$month[3] = "Avril" ;
$month[4] = "Mai" ;
$month[5] = "Juin" ;
$month[6] = "Juillet" ;
$month[7] = "Août" ;
$month[8] = "Septembre" ;
$month[9] = "Octobre" ;
$month[10] = "Novembre" ;
$month[11] = "Décembre" ;
// Première lettre des jours de la semaine
$day[0] = "D" ;
$day[1] = "L" ;
$day[2] = "M" ;
$day[3] = "M" ;
$day[4] = "J" ;
$day[5] = "V" ;
$day[6] = "S" ;
$error01 = "Erreur : date invalide"
?>
<html>
<head>
<style>
#general
{
font-family: Arial;
font-size: 10pt;
}
a:link,a:active,a:visited
{
text-decoration:none;
color:#000000;
}
a:hover
{
text-decoration:underline;
color:#000000;
}
</style>
<script language='JavaScript'>
function modifier (jour)
{
window.location.href = "./statistiques.php?form=<?echo $form;?>&elem=<?echo $elem;?>&mois=" + document.forms["MyCalendar"].elements['month'].options[document.forms["MyCalendar"].elements['month'].selectedIndex].value + "&jour=" + jour +"&annee=" + document.forms["MyCalendar"].elements['year'].options[document.forms["MyCalendar"].elements['year'].selectedIndex].value
}
<?
if (!isset($jour))
$jour = date("j") ;
if (!isset($mois))
$mois = date("m") ;
if (!isset($annee))
$annee = date("Y") ;
// nombre de jours par mois
$nbjmonth[0] = 31 ;
$nbjmonth[1] = ($annee%4==0?($annee%100==0?($annee%400?29:28):29):28) ;
$nbjmonth[2] = 31 ;
$nbjmonth[3] = 30 ;
$nbjmonth[4] = 31 ;
$nbjmonth[5] = 30 ;
$nbjmonth[6] = 31;
$nbjmonth[7] = 31 ;
$nbjmonth[8] = 30 ;
$nbjmonth[9] = 31 ;
$nbjmonth[10] = 30 ;
$nbjmonth[11] = 31 ;
if(!checkdate($mois,$jour,$annee))
{
echo "alert('$error01')\n" ;
$jour = date("j") ;
$mois = date("m") ;
$annee = date("Y") ;
}
// Calcul du jour julien et du numéro du jour
$HR = 0;
$GGG = 1;
if( $annee < 1582 ) $GGG = 0;
if( $annee <= 1582 && $mois < 10 ) $GGG = 0;
if( $annee <= 1582 && $mois == 10 && 1 < 5 ) $GGG = 0;
$JD = -1 * floor(7 * (floor(($mois + 9) / 12) + $annee) / 4);
$S = 1;
if (($mois - 9)<0) $S=-1;
$A = abs($mois - 9);
$J1 = floor($mois + $S * floor($A / 7));
$J1 = -1 * floor((floor($J1 / 100) + 1) * 3 / 4);
$JD = $JD + floor(275 * $mois / 9) + 1 + ($GGG * $J1);
$JD = $JD + 1721027 + 2 * $GGG + 367 * $annee - 0.5;
/*$tmp = ((int)(($mois>2?$annee:$annee-1)/100)) ;
$jj = (int)((((int)(365.25*($mois>2?$annee:$annee-1))) + ((int)(30.6001*($mois>2?$mois+1:$mois+13))) + $jour + 1720994.5 + ($annee > 1582 && $mois > 10 && $jour > 15?2-$tmp+((int)($tmp/4)):0))) ;
$jj = (int)(($jj) % 7)*/
$jj = (($JD+.5)%7) ;
?>
</script>
</head>
<?$datedebut= "$annee-$mois-$jour";
echo $datedebut->content;
echo "<body bgcolor='#$bgcolor' onUnLoad=''>\n" ;
echo "<center><form name='MyCalendar'>\n" ;
echo "<table width='170' cellspacing='0' cellspading='0' border='0'><tr>\n" ;
// Affichage de la sélection du mois et de l'année
echo "<td><select name='month' onChange=\"modifier($jour)\">\n" ;
for ($i=0;$i<12;$i++)
{
echo "<option value='".($i+1)."'".($mois==($i+1)?" selected":"").">".$month[$i]."</option>\n" ;
}
echo "</select></td>\n" ;
echo "<td align='right'><select name='year' onChange=\"modifier($jour)\">\n" ;
$y = date("Y") ;
for ($i=$y-10;$i<$y+10;$i++)
{
echo "<option value='$i'".($annee==($i)?" selected":"").">$i</option>\n" ;
}
echo "</select></td></tr><tr><td colspan='2'> </td></tr>\n" ;
echo "<tr><td colspan='2'><table width='100%' cellspacing='0' cellspading='0' border='0'>\n" ;
echo "<tr>\n" ;
// Affichage des jours
for($i=0;$i<7;$i++)
{
echo "<td width='14%' bgcolor='#$daybgcolor'><font id='general'>".$day[$i]."</font></td>" ;
}
echo "</tr>\n<tr><td colspan='7'> </td></tr>\n<tr>\n" ;
// Première ligne des jours
$j = $jj ;//date ("w", mktime (0,0,0,$mois,1,$annee)) ;
$dom = 1 ;
for ($i=0;$i<7;$i++)
{
if ($j<=$i)
{
echo "<td".($dom==$jour?" bgcolor='#$dombgcolor'":"")."><a href='javascript:modifier($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
}
else
echo "<td> </td>\n" ;
}
echo "</tr>\n" ;
// Le reste
for ($i=0;$i<5;$i++)
{
echo "<tr>\n" ;
for ($j=0;$j<7;$j++)
{
$j_inac = ($j==0 || $j==6) ;
if($dom < $nbjmonth[($mois-1)])
echo "<td".($dom==$jour?" bgcolor='#$dombgcolor'":($j_inac ?" bgcolor='#$dayholcolor'":""))."><a href='javascript:modifier($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
else if (checkdate($mois,$dom,$annee))
echo "<td".($dom==$jour?" bgcolor='#$dombgcolor'":($j_inac ?" bgcolor='#$dayholcolor'":""))."><a href='javascript:modifier($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
else
echo "<td> </td>\n" ;
}
echo "</tr>\n" ;
}
echo "\n</tr></table>\n" ;
echo "</td></tr></table>" ;
echo "</form></center>" ;
echo "</body>\n" ;
?>
//************************************************
//2eme calendrier***********************************
//************************************************
<td width="143" style="border-left-style: solid; border-left-width: 3; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1"><div align="left">
<center>
<b>date fin </b></td>
<td width="204" colspan="2" bgcolor="#E5E6E9" style="border-right-style:solid; border-right-width:3">
<?
// Section de configuration
$bgcolor="FBFBFB" ; // Couleur de fond
$dayfbgcolor="4B73F8" ; // Couleur des jourfs de la semaine
$dombgcolor="C1CEF9" ; // Couleur du jour sélectionné
$dayfholcolor="98EAF6" ; // Couleur des WE
// moisf
$monthf[0] = "Janvier" ;
$monthf[1] = "Février" ;
$monthf[2] = "Mars" ;
$monthf[3] = "Avril" ;
$monthf[4] = "Mai" ;
$monthf[5] = "Juin" ;
$monthf[6] = "Juillet" ;
$monthf[7] = "Août" ;
$monthf[8] = "Septembre" ;
$monthf[9] = "Octobre" ;
$monthf[10] = "Novembre" ;
$monthf[11] = "Décembre" ;
// Première lettre des jourfs de la semaine
$dayf[0] = "D" ;
$dayf[1] = "L" ;
$dayf[2] = "M" ;
$dayf[3] = "M" ;
$dayf[4] = "J" ;
$dayf[5] = "V" ;
$dayf[6] = "S" ;
$error01 = "Erreur : date invalide"
?>
<head>
<style>
#general
{
font-family: Arial;
font-size: 10pt;
}
a:link,a:active,a:visited
{
text-decoration:none;
color:#000000;
}
a:hover
{
text-decoration:underline;
color:#000000;
}
</style>
<script language='JavaScript'>
function modifierf (jourf)
{
window.location.href = "./statistiques.php?form=<?echo $form;?>&elem=<?echo $elem;?>&moisf=" + document.forms["Mycalendarf"].elements['monthf'].options[document.forms["Mycalendarf"].elements['monthf'].selectedIndex].value + "&jourf=" + jourf +"&anneef=" + document.forms["Mycalendarf"].elements['yearf'].options[document.forms["Mycalendarf"].elements['yearf'].selectedIndex].value
}
<?
if (!isset($jourf))
$jourf = date("j") ;
if (!isset($moisf))
$moisf = date("m") ;
if (!isset($anneef))
$anneef = date("Y") ;
// nombre de jourfs par moisf
$nbjmonthf[0] = 31 ;
$nbjmonthf[1] = ($anneef%4==0?($anneef%100==0?($anneef%400?29:28):29):28) ;
$nbjmonthf[2] = 31 ;
$nbjmonthf[3] = 30 ;
$nbjmonthf[4] = 31 ;
$nbjmonthf[5] = 30 ;
$nbjmonthf[6] = 31;
$nbjmonthf[7] = 31 ;
$nbjmonthf[8] = 30 ;
$nbjmonthf[9] = 31 ;
$nbjmonthf[10] = 30 ;
$nbjmonthf[11] = 31 ;
if(!checkdate($moisf,$jourf,$anneef))
{
echo "alert('$error01')\n" ;
$jourf = date("j") ;
$moisf = date("m") ;
$anneef = date("Y") ;
}
// Calcul du jourf julien et du numéro du jourf
$HR = 0;
$GGG = 1;
if( $anneef < 1582 ) $GGG = 0;
if( $anneef <= 1582 && $moisf < 10 ) $GGG = 0;
if( $anneef <= 1582 && $moisf == 10 && 1 < 5 ) $GGG = 0;
$JD = -1 * floor(7 * (floor(($moisf + 9) / 12) + $anneef) / 4);
$S = 1;
if (($moisf - 9)<0) $S=-1;
$A = abs($moisf - 9);
$J1 = floor($moisf + $S * floor($A / 7));
$J1 = -1 * floor((floor($J1 / 100) + 1) * 3 / 4);
$JD = $JD + floor(275 * $moisf / 9) + 1 + ($GGG * $J1);
$JD = $JD + 1721027 + 2 * $GGG + 367 * $anneef - 0.5;
/*$tmp = ((int)(($moisf>2?$anneef:$anneef-1)/100)) ;
$jj = (int)((((int)(365.25*($moisf>2?$anneef:$anneef-1))) + ((int)(30.6001*($moisf>2?$moisf+1:$moisf+13))) + $jourf + 1720994.5 + ($anneef > 1582 && $moisf > 10 && $jourf > 15?2-$tmp+((int)($tmp/4)):0))) ;
$jj = (int)(($jj) % 7)*/
$jj = (($JD+.5)%7) ;
?>
</script>
</head>
<?$datefin= "$anneef-$moisf-$jourf";
echo "<body bgcolor='#$bgcolor' onUnLoad=''>\n" ;
echo "<center><form name='Mycalendarf'>\n" ;
echo "<table width='170' cellspacing='0' cellspading='0' border='0'><tr>\n" ;
// Affichage de la sélection du moisf et de l'année
echo "<td><select name='monthf' onChange=\"modifierf($jourf)\">\n" ;
for ($i=0;$i<12;$i++)
{
echo "<option value='".($i+1)."'".($moisf==($i+1)?" selected":"").">".$monthf[$i]."</option>\n" ;
}
echo "</select></td>\n" ;
echo "<td align='right'><select name='yearf' onChange=\"modifierf($jourf)\">\n" ;
$y = date("Y") ;
for ($i=$y-10;$i<$y+10;$i++)
{
echo "<option value='$i'".($anneef==($i)?" selected":"").">$i</option>\n" ;
}
echo "</select></td></tr><tr><td colspan='2'> </td></tr>\n" ;
echo "<tr><td colspan='2'><table width='100%' cellspacing='0' cellspading='0' border='0'>\n" ;
echo "<tr>\n" ;
// Affichage des jourfs
for($i=0;$i<7;$i++)
{
echo "<td width='14%' bgcolor='#$dayfbgcolor'><font id='general'>".$dayf[$i]."</font></td>" ;
}
echo "</tr>\n<tr><td colspan='7'> </td></tr>\n<tr>\n" ;
// Première ligne des jourfs
$j = $jj ;//date ("w", mktime (0,0,0,$moisf,1,$anneef)) ;
$dom = 1 ;
for ($i=0;$i<7;$i++)
{
if ($j<=$i)
{
echo "<td".($dom==$jourf?" bgcolor='#$dombgcolor'":"")."><a href='javascript:modifierf($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
}
else
echo "<td> </td>\n" ;
}
echo "</tr>\n" ;
// Le reste
for ($i=0;$i<5;$i++)
{
echo "<tr>\n" ;
for ($j=0;$j<7;$j++)
{
$j_inac = ($j==0 || $j==6) ;
if($dom < $nbjmonthf[($moisf-1)])
echo "<td".($dom==$jourf?" bgcolor='#$dombgcolor'":($j_inac ?" bgcolor='#$dayfholcolor'":""))."><a href='javascript:modifierf($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
else if (checkdate($moisf,$dom,$anneef))
echo "<td".($dom==$jourf?" bgcolor='#$dombgcolor'":($j_inac ?" bgcolor='#$dayfholcolor'":""))."><a href='javascript:modifierf($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
else
echo "<td> </td>\n" ;
}
echo "</tr>\n" ;
}
//echo "\n<tr><td colspan='10' align='center'><input type='button' onclick='window.opener.document.forms[\"$form\"].elements[\"$elem\"].value=\"$anneef-$moisf-$jourf\";window.close()' value='Valider'> <input onclick='window.close()' type='button' value='Annuler'></td></tr></table>\n" ;
echo "\n</tr></table>\n" ;
echo "</td></tr></table>" ;
echo "</form></center>" ;
echo "</body>\n" ;
?></td>
</tr>
</table>
<?
$date1= $datedebut;
$date2= $datefin;
?>
</form>
//ensuite ça part sur la partie stat du prog...