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

Langage PHP Discussion :

problème avec un script javascript en php


Sujet :

Langage PHP

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 27
    Points : 16
    Points
    16
    Par défaut problème avec un script javascript en php
    Le problème est que une de mes fonctions javascript fonctionne correctement dans le fichier courant et envoie bien dans le get les variables demandées mais lorsque je l'intègre à un autre fichier je n'ai plus les variables dans le get
    c'est la fonction 'or' qui déconne.
    Voilà le code, il fait un calendrier :

    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
     
    <?
    /* C'est cette fonction qui ne va pas elle est en commentaire car elle est je l'ai mise dans le fichier principal qui suit
    script language="JavaScript">
    <!--
    // please keep these lines on when you copy the source
    // made by: Nicolas - <a href="http://www.javascript-page.com" target="_blank">http://www.javascript-page.com</a>
    
    function or( d,m,ye, nb) {
    //   alert ("You can get an alert or " + j + " confirm message to show up");
     m=m-1;
     document.location.href="?day="+d+"&month="+m+"&year="+ye+"&nb="+nb
    }
    // -->
    </script>
    */
    function cal_days_in_month( $mys, $month, $year) {
    if(checkdate($month, 31, $year)) return 31;
    if(checkdate($month, 30, $year)) return 30;
    if(checkdate($month, 29, $year)) return 29;
    if(checkdate($month, 28, $year)) return 28;
    return 0; // error
    }
    /*
    if(!isset($_REQUEST["m"]) ) $m = date("n");
    else $m=$_REQUEST["m"];
    if(!isset($_REQUEST["a"]) ) $a = date("Y");
    else $a=$_REQUEST["a"];
    */
    function calendar( $firstDate, $lastDate, $number, $a, $m )
    {/*
     global $m;
     global $a;*/
     
    $mnom = Array("","Janvier","Février","Mars"
       ,"Avril","Mai","Juin","Juillet","Août"
       ,"Septembre","Octobre","Novembre","Décembre");
    $dayone = date("w",mktime(1,1,1,$m,1,$a));
    if($dayone==0) $dayone=7;
     
    $url = $_SERVER['PHP_SELF'];
    $aplus=$a+1;
    $amoins=$a-1;
    ?>
      <style type="text/css">
    <!--
    a:link,a:active,a:visited
    {
     
       text-decoration:none;
       color: #000000;
    }
    tr.impaire {
     
       background-color:#f9f8f1;
     
    }
     
    tr.paire {
     
       background-color:#f2efe3;
     
    }
    body {
    font-size:10px;
       background-color: #FFFFFF;
    }
    -->
    </style>
       <script type="text/javascript">
       function surligne(elt){
       elt.style.backgroundColor="#4A7E1E";
       }
       function surligneoff(elt){
       elt.style.backgroundColor="#FFFFFF";
       }
       </script>
    <font size=1>
    <? if($amoins>=($firstDate[0]+2001)){?> <a href="<? echo $url."?m=12&a=".$amoins."&number=".$number; ?>"><<</a>&nbsp;
       <? } // 10 ans avant ?>
     
     <? 
     for($i=$a-1;$i<=$a;$i++) {?>
    <?  if($i>=($firstDate[0]+2000) && $i<=date("Y")+5){?>  <a href="<? echo $url."?m=".$m."&a=".$i."&number=".$number; ?>">
          <? echo $i; ?></a><? } ?>
    <? } ?>
    <? if($aplus<=date("Y")){?>&nbsp;<a href="<? echo $url."?m=1&a=".$aplus."&number=".$number; ?>">>></a>
       <? }// 10 ans apres ?>
    <br><br><? if($a==($firstDate[0]+2000)) {for($i=$firstDate[1];$i<=12;$i++) { ?>
       <a href="<? echo $url."?m=".$i."&a=".$a."&number=".$number; ?>">
          <? echo substr($mnom[$i],0,1); ?></a>
         <? if($i!=12 && $i!=$firstDate[1]) echo " - "; }} ?>
    	<? if($a==($lastDate[0]+2000)) {for($i=1;$i<=$lastDate[1];$i++) { ?>
       <a href="<? echo $url."?m=".$i."&a=".$a."&number=".$number; ?>">
          <? echo substr($mnom[$i],0,1); ?></a>
         <? if($i!=$lastDate[1]) echo " - "; }} ?>
    	<? if($a>($firstDate[0]+2000) && $a<($lastDate[0]+2000)) {for($i=1;$i<=12;$i++) { ?>
       <a href="<? echo $url."?m=".$i."&a=".$a."&number=".$number; ?>">
          <? echo substr($mnom[$i],0,1); ?></a>
         <? if($i!=12) echo " - "; }} ?>
         <br/><br/>
    </font>
    <font size=2>
    <? if(($m==$firstDate[1] && $a<=($firstDate[0]+2000))==false){ ?>
    <a href="<? 
    if($m==1){
     $an=$a-1;
     $mois=12;
     }
     else{
     $an=$a;
     $mois=$m-1;
     }
     
     
    echo $url."?m=".$mois."&a=".$an."&number=".$number; ?>"><<</a>&nbsp;<? } // mois avant ?>
    <? echo $mnom[$m]." ".$a; ?>
    <? if(($m==$lastDate[1] && $a>=($lastDate[0]+2000))==false){ ?>
     <? 
     if($m==12){
     $an=$a+1;
     $mois=1;
     }
     else{
     $an=$a;
     $mois=$m+1;
     }
     
     ?>
     
     &nbsp;<a href="<? echo $url."?m=".$mois."&a=".$an."&number=".$number; ?>">>></a><? }// mois apres ?></font>
    <br><br>
    <table width="170" cellspacing=0 border>
       <tr  class="paire">
          <th>L</th>
         <th>M</th>
         <th>M</th>
         <th>J</th>
         <th>V</th>
         <th>S</th>
         <th>D</th>
       <? for($i=1;$i<=42;$i++) {
          if($i%7 == 1) { ?></tr><tr><? }
          if(($i<((cal_days_in_month(CAL_GREGORIAN,$m,$a)+$dayone))&&($i>=$dayone))&&(((($m==$firstDate[1])&&($i>=($firstDate[2]+$dayone-1))))||(($m==$lastDate[1])&&($i<($lastDate[2]+$dayone)))||(($m!=$firstDate[1])&&($m!=$lastDate[1])))) { ?>
       <?// if(($m!=$firstDate[1] || ($i>$firstDate[2]+$dayone))&&($m!=$lastDate[1] || $i<$lastDate[2]+$dayone)){ ?>
             <th  onMouseOut="javascript:surligneoff(this);" onMouseOver="javascript:surligne(this);"  >
             <? $day=$i-$dayone+1; echo "<a href='' onClick='or(".$day.",".$number.")'>"; echo $i-$dayone+1; ?></a></th>
          <?  }
         else { ?>
             <th bgcolor=silver>&nbsp;</th>
          <? }
       } ?>
    </table>
    <?
    }
    /*
    $date1[0]="06";
    $date1[1]="06";
    $date1[2]="06";
    $date2[0]="08";
    $date2[1]="07";
    $date2[2]="25";
    calendar($date1,$date2, 1);
    */
    ?>
    et le fichier principal où cette fonction est utilisée se trouve ci-dessous

    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
     
    <script type="text/javascript">
    <!--
    function montre(id) {
    var d = document.getElementById(id);
    	for (var i = 0; i<=31; i++) {
    		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
    	}
    if (d) {d.style.display='block';}
    }
    //-->
    </script>
    <script type="text/javascript">
    <!--
    // please keep these lines on when you copy the source
    // made by: Nicolas - <a href="http://www.javascript-page.com" target="_blank">http://www.javascript-page.com</a>
     
    function or( d,nb) {
    //   alert ("You can get an alert or " + j + " confirm message to show up");
     m=m-1;
     document.location.href="?day="+d+"&nb="+nb
    }
    // -->
    </script>
    <?php
    // $time_start = microtime(true);
     include( "graph.php" );
     include( "sgbd.inc.php" );
     include( "calendar.inc.php" );
     
     
     $lastDate = sgbdGetLastDate( $errorMsg );
     $firstDate = sgbdGetFirstDate( $errorMsg );
     
    /*
     if( !isset( $_GET['year'] ) )
    	{
    	 $year=$lastDate[0];
    	 $month=$lastDate[1];
    	 $day=$lastDate[2];
    	}
     else
    	{
    	 $year=$_GET['year'];
    	 $month=$_GET['month'];
    	 $day=$_GET['day'];
    	}
    */
     
     if( !isset( $_POST['year'] ) )
    	{
    	 $year=$lastDate[0];
    	 $month=$lastDate[1];
    	 $day=$lastDate[2];
    	}
     else
    	{
    	 $year=$_POST['year'];
    	 $month=$_POST['month'];
    	 $day=$_POST['day'];
    	}
     
     
     $a1="20".$lastDate[0];
     $m1=$lastDate[1];
    // $d1=$lastDate[2];
     $a2="20".$lastDate[0];
     $m2=$lastDate[1];
    // $d2=$lastDate[2];
     
     if( isset( $_GET['number'] ) )
    	{
    	 $number=$_GET['number'];
    	 if($number==1)
    		{
    	 	 $m1=$_GET["m"];
    	 	 $a1=$_GET["a"];
    	 	 $m2=$_COOKIE['mois2'];
    	 	 $a2=$_COOKIE['annee2'];
    		 setcookie( "mois1",$m1 );
    		 setcookie( "annee1", $a1 );
    		 setcookie( "number", $number );
    		}
    	 if($number==2)
    		{
    	 	 $m2=$_GET["m"];
    	 	 $a2=$_GET["a"];
    		 $m1=$_COOKIE['mois1'];
    		 $a1=$_COOKIE['annee1'];
    		 setcookie( "mois2",$m2 );
    		 setcookie( "annee2", $a2 );
    		}
    	}
     
     if( isset( $_GET['day'] ) )
    	{
    	 echo "sdk<br>";
    	 if( $_GET['nb']==1 )
    		 setcookie( "day1",$_GET['day'] );
    	 if( $_GET['nb']==2 )
    	 	 setcookie( "day2",$_GET['day'] );
    	}
     
     $d1=$_COOKIE['day1'];
     $d2=$_COOKIE['day2'];
     
     $errorMsg="";
     $yearList = sgbdYearList( $errorMsg );
     
    /*
    
    $date1[0]="06";
    $date1[1]="06";
    $date1[2]="06";
    $date2[0]="08";
    $date2[1]="07";
    $date2[2]="25";
    
     echo "<th><td>";
     calendar($date1,$date2,1, "07", "07");
     echo "</td><td>";
     calendar($date1,$date2,2, "08", "01");
     echo "</td></th>";
    */
     echo "<table width='620'>";
     echo "<tr><td>";
     echo "Début </td><td>";
     calendar($firstDate,$lastDate,1, $a1, $m1);
     echo "</td><td>";
     echo "Fin </td><td>";
     calendar($firstDate,$lastDate,2, $a2, $m2);
     echo "</td><td>";
     echo "<form method='POST' action='".$_SERVER['PHP_SELF']."'>";
     echo "<input type='hidden' name='year' value=''>";
     echo "<input type='hidden' name='month' value=''>";
     echo "<input type='hidden' name='day' value=''>";
     echo "<input type='submit' class='bouton' value='OK'>";
     echo "</form>";
     echo "</td></tr>";
     echo "<tr><td></td><td>$a1"." $m1"." $d1</td>";
     echo "<td></td><td>$a2"." $m2"." $d2</td><td></td></tr>";
     echo "</table>";
    /*
     echo "<form name='selection' method='GET' action='" . $_SERVER['PHP_SELF'] . "'>";
    
     echo "<SELECT name='year' onChange='Javascript:document.selection.month.value=0; document.selection.day.value=0; document.selection.submit();'>";
     echo "<OPTION value='' >Année</OPTION>";
     foreach( $yearList as $lyear )
     { $selected = "";
       $value=$lyear[2].$lyear[3];
       if( $value==$year ) $selected = "select selected";
       echo "<OPTION value='$value' $selected > $lyear </OPTION>";
     }
     echo "</SELECT>";
    
     echo "<SELECT name='month' onChange='Javascript: document.selection.day.value=0; document.selection.submit();'>";
     echo "<OPTION value='0' >Mois</OPTION>";
     $i=1;
     foreach( $monthName as $name )
     { $selected = "";
       if( $i<10 ) $value="0".$i;
       else $value=$i;
       if( $value==$month ) $selected = "select selected";
       echo "<OPTION value='$value' $selected > $name </OPTION>";
       $i++;
     }
     echo "</SELECT>";
    
     echo "<SELECT name='day' onChange='Javascript:document.selection.submit();'>";
     echo "<OPTION value='0' >Jours</OPTION>";
     foreach( $dayName as $name )
     { $selected = "";
       if( $name==$day ) $selected = "select selected";
       echo "<OPTION value='$name' $selected > $name </OPTION>";
     }
     echo "</SELECT>";
    
     echo "<BR>";
     echo "<BR>";
    
     echo "<INPUT type='radio' name='radio' value='current'>Courant";
     echo "<INPUT type='radio' name='radio' value='voltage'>Tension";
     echo "<INPUT type='radio' name='radio' value='chloride'>Chlorure";
    
     echo "</form>";
    */
     
     
    $ackCurrent=sgbdGetValue ( "current", $year, $month, $day, $errorMsg );
    $ackVoltage=sgbdGetValue ( "voltage", $year, $month, $day, $errorMsg );
    $ackReferencePotential=sgbdGetValue ( "referencePotential", $year, $month, $day, $errorMsg );
    $ackReturnPotential=sgbdGetValue ( "returnPotential", $year, $month, $day, $errorMsg );
     
     
    $ackDefaultsNumber=sgbdGetNumber( "defaults", $year, $month, $day, $errorMsg );
    $ackEventsNumber=sgbdGetNumber( "events", $year, $month, $day, $errorMsg );
    $ackCommentsNumber=sgbdGetNumber( "comments", $year, $month, $day, $errorMsg );
    /*foreach ( $ackReferencePotential as $number )
       { echo $number;
         echo "<br>";
       }*/
     
    /* $time_end = microtime(true);
     $time = $time_end - $time_start;
     echo $time;
    */
    $characteristics=graphPrint( $ackCurrent, $ackVoltage, $ackReferencePotential, $ackReturnPotential, $ackDefaultsNumber, $ackEventsNumber, $ackCommentsNumber );
     
    echo "<img src=\"./graph.png\" USEMAP=\"#map\" border=0>\n";
    echo "<div class='graphvisits' >\n";
    echo "<MAP ID=\"map\" NAME=\"map\">\n";
    for( $i=0;$i<$characteristics[2];$i++ )
    	{
    	 $x1=$characteristics[0] + $i*$characteristics[1];
    	 $x2=$characteristics[0] + ($i+1)*$characteristics[1];
     
    	 //echo '<AREA SHAPE="RECT" COORDS="0,0,20,20" href="http://www.startyourdev.com"  >'."\n";
    	 echo '<AREA SHAPE="RECT" COORDS="'.$x1.",0,".$x2.",".$characteristics[3].'" onmouseover="javascript:montre('."'smenu".$i."');".'" onmouseout="javascript:montre();">'."\n";
    	 //echo '<AREA SHAPE="RECT" COORDS="'.$x1.",0,".$x2.",".$characteristics[3].'" href="http://www.startyourdev.com">'."\n";
    	}
    //<AREA SHAPE="RECT" COORDS="88,30,110,280" onmouseover="javascript:montre('smenu10');" onmouseout="javascript:montre();">
    echo "</MAP>\n";
     
    for( $i=0;$i<$characteristics[2];$i++ )
    	{
    	 echo '<div id="smenu'.$i.'"  style="padding:10px; display:none; width:170px; font-size:13px; color:#003399; font-family:Verdana,Geneva, Arial, Helvetica, Sans-Serif; text-align:left; border:2px solid navy; position:absolute; top:8px; left:300px; background:#eee;">'."\n";
    	 echo " Voltage : ".round($voltage[$i],2)."V <br> Courant : ".round($current[$i],2)."A<br>";
    	 echo " Consigne Pot. : ".round($referencePotential[$i],2)."V<br> Potentiel : ".round($returnPotential[$i],2)."V"."\n";
    	 echo "</div>\n";
    	}
    echo "</div>\n";
    /*
    $defaultsList = sgbdGetEvents ( "defaults","07","05",0, $errorMsg );
    $defaultsList = sgbdGetEvents ( "events","07","05",0, $errorMsg );
    $commentsList = sgbdGetComments ( "07","05",0, $errorMsg );
    */
    ?>

  2. #2
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Bonjour

    Déjà, le fait d'appeler une fonction "or", alors que c'est un mot clé php, n'est pas nécessairement une bonne idée. Bon, comme c'est une fonction JS ça ne devrait pas poser de problème, mais quand même...

    Ensuite, je n'arrive pas à repérer où tu fais appel à cette fonction.
    Modératrice PHP
    Aucun navigateur ne propose d'extension boule-de-cristal : postez votre code et vos messages d'erreurs. (Rappel : "ça ne marche pas" n'est pas un message d'erreur)
    Cherchez un peu avant poser votre question : Cours et Tutoriels PHP - FAQ PHP - PDO une soupe et au lit !.

    Affichez votre code en couleurs : [CODE=php][/CODE] (bouton # de l'éditeur) et [C=php][/C]

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 27
    Points : 16
    Points
    16
    Par défaut
    C'est tout à la fin du premier code, elle sert à envoyer la variable du jour sélectionné quand on clique dessus avec la souris

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
            <th  onMouseOut="javascript:surligneoff(this);" onMouseOver="javascript:surligne(this);"  >
             <? $day=$i-$dayone+1; echo "<a href='' onClick='or(".$day.",".$number.")'>"; echo $i-$dayone+1; ?></a></th>
          <?  }
         else { ?>
             <th bgcolor=silver>&nbsp;</th>

  4. #4
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    donc le premier code est un de ces fichiers inclus je suppose :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     include( "graph.php" );
     include( "sgbd.inc.php" );
     include( "calendar.inc.php" );
    Est-ce que, dans le code source de la page dans le navigateur web, tu retrouves ta fonction JS?
    Modératrice PHP
    Aucun navigateur ne propose d'extension boule-de-cristal : postez votre code et vos messages d'erreurs. (Rappel : "ça ne marche pas" n'est pas un message d'erreur)
    Cherchez un peu avant poser votre question : Cours et Tutoriels PHP - FAQ PHP - PDO une soupe et au lit !.

    Affichez votre code en couleurs : [CODE=php][/CODE] (bouton # de l'éditeur) et [C=php][/C]

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 27
    Points : 16
    Points
    16
    Par défaut
    oui c'est calendar.inc.php
    Je retrouve bien ma fonction js dans le code source de la page

    lorsque je met tout dans le meme fichier, il n'y a pas de problème, il envoie ce qu'il faut dans le get

    par exemple ce code là fonctionne
    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
     
    <script language="JavaScript">
    <!--
    // please keep these lines on when you copy the source
    // made by: Nicolas - http://www.javascript-page.com
     
    function or( d,m,ye, nb) {
    //   alert ("You can get an alert or " + j + " confirm message to show up");
     m=m-1;
     document.location.href="?day="+d+"&month="+m+"&year="+ye+"&nb="+nb
    }
    // -->
    </script>
    <?
    function cal_days_in_month( $mys, $month, $year) {
    if(checkdate($month, 31, $year)) return 31;
    if(checkdate($month, 30, $year)) return 30;
    if(checkdate($month, 29, $year)) return 29;
    if(checkdate($month, 28, $year)) return 28;
    return 0; // error
    }
     
    if(!isset($_REQUEST["m"]) ) $m = date("n");
    else $m=$_REQUEST["m"];
    if(!isset($_REQUEST["a"]) ) $a = date("Y");
    else $a=$_REQUEST["a"];
     
    function calendar( $firstDate, $lastDate, $number )
    {
     global $m;
     global $a;
    $mnom = Array("","Janvier","Février","Mars"
       ,"Avril","Mai","Juin","Juillet","Août"
       ,"Septembre","Octobre","Novembre","Décembre");
    $dayone = date("w",mktime(1,1,1,$m,1,$a));
    if($dayone==0) $dayone=7;
     
    $url = $_SERVER['PHP_SELF'];
    $aplus=$a+1;
    $amoins=$a-1;
    ?>
      <style type="text/css">
    <!--
    a:link,a:active,a:visited
    {
     
       text-decoration:none;
       color: #000000;
    }
    tr.impaire {
     
       background-color:#f9f8f1;
     
    }
     
    tr.paire {
     
       background-color:#f2efe3;
     
    }
    body {
    font-size:10px;
       background-color: #FFFFFF;
    }
    -->
    </style>
       <script type="text/javascript">
       function surligne(elt){
       elt.style.backgroundColor="#4A7E1E";
       }
       function surligneoff(elt){
       elt.style.backgroundColor="#FFFFFF";
       }
       </script>
    <? if($amoins>=($firstDate[0]+2001)){?> <a href="<? echo $url."?m=12&a=".$amoins; ?>"><<</a>&nbsp;
       <? } // 10 ans avant ?>
     
     <? 
     for($i=$a-1;$i<=$a;$i++) {?>
    <?  if($i>=($firstDate[0]+2000) && $i<=date("Y")+5){?>  <a href="<? echo $url."?m=".$m."&a=".$i; ?>">
          <? echo $i; ?></a><? } ?>
    <? } ?>
    <? if($aplus<=date("Y")){?>&nbsp;<a href="<? echo $url."?m=1&a=".$aplus; ?>">>></a>
       <? }// 10 ans apres ?>
    <br><br><? if($a==($firstDate[0]+2000)) {for($i=$firstDate[1];$i<=12;$i++) { ?>
       <a href="<? echo $url."?m=".$i."&a=".$a; ?>">
          <? echo substr($mnom[$i],0,1); ?></a>
         <? if($i!=12 && $i!=$firstDate[1]) echo " - "; }} ?>
    	<? if($a==($lastDate[0]+2000)) {for($i=1;$i<=$lastDate[1];$i++) { ?>
       <a href="<? echo $url."?m=".$i."&a=".$a; ?>">
          <? echo substr($mnom[$i],0,1); ?></a>
         <? if($i!=$lastDate[1]) echo " - "; }} ?>
    	<? if($a>($firstDate[0]+2000) && $a<($lastDate[0]+2000)) {for($i=1;$i<=12;$i++) { ?>
       <a href="<? echo $url."?m=".$i."&a=".$a; ?>">
          <? echo substr($mnom[$i],0,1); ?></a>
         <? if($i!=12) echo " - "; }} ?>
         <br/><br/>
    <font size=4>
    <? if(($m==$firstDate[1] && $a<=($firstDate[0]+2000))==false){ ?>
    <a href="<? 
    if($m==1){
     $an=$a-1;
     $mois=12;
     }
     else{
     $an=$a;
     $mois=$m-1;
     }
     
     
    echo $url."?m=".$mois."&a=".$an; ?>"><<</a>&nbsp;<? } // mois avant ?>
    <? echo $mnom[$m]." ".$a; ?>
    <? if(($m==$lastDate[1] && $a>=($lastDate[0]+2000))==false){ ?>
     <? 
     if($m==12){
     $an=$a+1;
     $mois=1;
     }
     else{
     $an=$a;
     $mois=$m+1;
     }
     
     ?>
     
     &nbsp;<a href="<? echo $url."?m=".$mois."&a=".$an; ?>">>></a><? }// mois apres ?></font>
    <br><br>
    <table width="170" cellspacing=0 border>
       <tr  class="paire">
          <th>L</th>
         <th>M</th>
         <th>M</th>
         <th>J</th>
         <th>V</th>
         <th>S</th>
         <th>D</th>
       <? for($i=1;$i<=42;$i++) {
          if($i%7 == 1) { ?></tr><tr><? }
          if(($i<((cal_days_in_month(CAL_GREGORIAN,$m,$a)+$dayone))&&($i>=$dayone))&&(((($m==$firstDate[1])&&($i>=($firstDate[2]+$dayone-1))))||(($m==$lastDate[1])&&($i<($lastDate[2]+$dayone)))||(($m!=$firstDate[1])&&($m!=$lastDate[1])))) { ?>
       <?// if(($m!=$firstDate[1] || ($i>$firstDate[2]+$dayone))&&($m!=$lastDate[1] || $i<$lastDate[2]+$dayone)){ ?>
             <th  onMouseOut="javascript:surligneoff(this);" onMouseOver="javascript:surligne(this);"  >
             <? $day=$i-$dayone+1; echo "<a href='' onClick='or(".$day.",".$mois.",".$an.",".$number.")'>"; echo $i-$dayone+1; ?></a></th>
          <?  }
         else { ?>
             <th bgcolor=silver>&nbsp;</th>
          <? }
       } ?>
    </table>
    <?
    }
     
    $date1[0]="06";
    $date1[1]="06";
    $date1[2]="06";
    $date2[0]="08";
    $date2[1]="07";
    $date2[2]="25";
    calendar($date1,$date2,1);
     
    ?>

Discussions similaires

  1. Problème avec mon script php
    Par michou2008 dans le forum Autres langages pour le Web
    Réponses: 0
    Dernier message: 04/05/2014, 01h44
  2. [AJAX] avec 3 listes déroulantes liées php+xhtml+css+javascript+ajax
    Par Invité dans le forum Général JavaScript
    Réponses: 10
    Dernier message: 27/12/2008, 15h54
  3. [PHP-JS] problème avec mon script de connexion
    Par agencep dans le forum Langage
    Réponses: 5
    Dernier message: 31/01/2008, 17h08
  4. [PHP-JS] Problème avec un script php d'un formulaire
    Par Dark DJ dans le forum Langage
    Réponses: 3
    Dernier message: 11/06/2006, 19h36
  5. Probleme avec un script javascript->php
    Par leluis dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 23/03/2006, 15h32

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