[Décompte] Serez-vous m'aidez ?

Bonjour,

J'ai un code html très intéréssant pour faire un décompte mais j'ai un petit problème puisque celui çi et sous forme de formulaire. Avez-vous une solution pour changer le formulaire par du texte brut ? Passé d'un format formulaire à un format d'écriture normale ?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
	<TITLE>Décompte JavaScript</TITLE>
	<SCRIPT LANGUAGE="JavaScript">
		
		var Mois = new Array(12);
		var Jours = new Array(7);
		
		function Decompte(msg1,msg2,endmsg,datetemoin,cible,Fonction) {
		
			this.Target = cible;
			this.fonction = Fonction + '.Affiche()';	// Nom de l'objet JavaScript
			this.timeout = null;
			this.datebase = new Date(datetemoin);
			this.mesg1 = msg1;
			this.mesg2 = msg2;
			this.end = endmsg;
			this.ToStop = false;
		
			this.Init = Initialise;
			this.Affiche = Affichage;
			this.Stop = StopAll;
		
			this.Init();
			this.Affiche();
		}
		
		function Initialise() {
			var cur = new Date();
			var diff = this.datebase.getTime() - cur.getTime();
			this.ToStop = (this.end != '');
		}
		
		function Affichage() {
			var out;
			curdate = new Date();
			if ( (this.ToStop) && ( (this.datebase.getTime() - curdate.getTime()) <= 0 ) ) {
				if (this.Target == "") {
					window.status = this.end;
				}
				else {
					this.Target.value = this.end;
				}
				StopAll();
			}
			else {
				difference = Math.abs(this.datebase.getTime() - curdate.getTime());
				difference = Math.floor(difference / 1000);
				nbj = Math.floor(difference / 86400);
				difference = difference % 86400;
				nbh = Math.floor(difference / 3600);
				difference = difference % 3600;
				nbm = Math.floor(difference / 60);
				difference = difference % 60;
				nbs = difference;
				out = this.mesg1 + ' ' + nbj;
				if (nbj == 1) 
					out += ' jour ' + nbh;
				else
					out += ' jours ' + nbh;
				if (nbh == 1)
					out += ' heure ' + nbm;
				else
					out += ' heures ' + nbm;
				if (nbm == 1)
					out += ' minute ' + nbs;
				else
					out += ' minutes ' + nbs;
				if (nbs == 1)
					out += ' seconde ' + this.mesg2;
				else out += ' secondes ' + this.mesg2;
		
				if (this.Target == "") {
					window.status = out;
				}
				else {
					this.Target.value = out;
				}
				this.timeout = window.setTimeout(this.fonction,1000);
			}
		}	
		
		// Fonction Arret
		function StopAll() {
			clearTimeout(this.timeout);
			this.timeout = null;
		}
		//-->
	</SCRIPT>
</HEAD>

<BODY onLoad = "LeDecompte = new Decompte('Il reste','avant l\'an 2000','Bonne Année. Bienvenue dans le nouveau millénaire!','31 dec, 1999 23:59:59',document.JSCLOCK.CLOCK,'LeDecompte');"
	onUnload = 'LeDecompte.Stop();'>

<CENTER>
<FORM NAME="JSCLOCK">
<INPUT NAME="CLOCK" SIZE=65 VALUE="champ 1"><BR>
</FORM>
</CENTER>
</BODY>
</HTML>
Configuration: Windows Vista
Internet Explorer 7.0

3 réponses

  • Votes
  • Date
  • Date décroissante
  1. Contributeur
    salut,
    changer les valeur :
    $targetYear = 2009;
    $targetMonth = 01;
    $targetDay = 01;
    $targetHour = 00;
    $targetMinute= 00;
    $targetSecond= 00;

    <?php
    ////////////////////////////////////
    // Décompte System                //
    // https://www.commentcamarche.net/ //
    // Auto : smed79                  //
    ////////////////////////////////////
    ?>
    
    <?php
    // Préciser votre date cible ici
    	$targetYear  = 2009;
    	$targetMonth = 01;
    	$targetDay   = 01;
    	$targetHour  = 00;
    	$targetMinute= 00;
    	$targetSecond= 00;
    // Fin de date
    
    // Définir le format de date
    $dateFormat = "Y-m-d H:i:s";
    
    $targetDate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear);
    $actualDate = time();
    
    $secondsDiff = $targetDate - $actualDate;
    
    $remainingDay     = floor($secondsDiff/60/60/24);
    $remainingHour    = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
    $remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
    $remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));
    
    $targetDateDisplay = date($dateFormat,$targetDate);
    
    ?>
    
    <html>
    <head>
    <title>Décompte JavaScript System - commentcamarche.net - smed79</title>
    <script type="text/javascript">
      var days = <?php echo $remainingDay; ?>  
      var hours = <?php echo $remainingHour; ?>  
      var minutes = <?php echo $remainingMinutes; ?>  
      var seconds = <?php echo $remainingSeconds; ?>  
    
    function setCountDown ()
    {
      seconds--;
      if (seconds < 0){
          minutes--;
          seconds = 59
      }
      if (minutes < 0){
          hours--;
          minutes = 59
      }
      if (hours < 0){
          days--;
          hours = 23
      }
      document.getElementById("remain").innerHTML = days+" jours, "+hours+" heures, "+minutes+" minutes, "+seconds+" secondes";
      setTimeout ( "setCountDown()", 1000 );
    }
    
    </script>
    </head>
    
    <body onload="setCountDown();">
    
            <table>
            
                 <tr>
                   <td>Il reste <th id="remain"><?php echo "$remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds";?></th>
                   </td>
                   <td>avant l'an : <?php echo $targetDateDisplay; ?>
                   </td>
                 </tr>
    
           </table>
        </div>
    </div>
    </body>
    </html>


    si vous trouvez des erreurs merci de les corriger !
    1. Dites les gars, je suis une bille en informatique (tt du moins du coté de la prog, suis illustrateur et je touche un peu a la 3D) et j'ai une date importante pour moi : le 19juin 2009 ce jour la il m'arrivera un truc extraordinaire :D. Serais t'il possible d'avoir un décompte tout simple que je garderai precieusement etant donné mon impatience ;x

      Thx les gars!
      1. Contributeur
        <?php
        ////////////////////////////////////
        // Décompte System                //
        // https://www.commentcamarche.net/ //
        // Auto : smed79                  //
        ////////////////////////////////////
        ?>
        
        <?php
        // Préciser votre date cible ici
        	$targetYear  = 2009;
        	$targetMonth = 06;
        	$targetDay   = 19;
        	$targetHour  = 00;
        	$targetMinute= 00;
        	$targetSecond= 00;
        // Fin de date
        
        // Définir le format de date
        $dateFormat = "Y-m-d H:i:s";
        $targetDate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear);
        $actualDate = time();
        $secondsDiff = $targetDate - $actualDate;
        $remainingDay     = floor($secondsDiff/60/60/24);
        $remainingHour    = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
        $remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
        $remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));
        $targetDateDisplay = date($dateFormat,$targetDate);
        ?>
        
        <html>
        <head>
        <title>Décompte JavaScript System - commentcamarche.net - smed79</title>
        <script type="text/javascript">
          var days = <?php echo $remainingDay; ?>  
          var hours = <?php echo $remainingHour; ?>  
          var minutes = <?php echo $remainingMinutes; ?>  
          var seconds = <?php echo $remainingSeconds; ?>  
        function setCountDown ()
        {
          seconds--;
          if (seconds < 0){
              minutes--;
              seconds = 59
          }
          if (minutes < 0){
              hours--;
              minutes = 59
          }
          if (hours < 0){
              days--;
              hours = 23
          }
          document.getElementById("remain").innerHTML = days+" jours, "+hours+" heures, "+minutes+" minutes, "+seconds+" secondes";
          setTimeout ( "setCountDown()", 1000 );
        }
        </script>
        </head>
        <body onload="setCountDown();">
                <table>
                     <tr>
                       <td>Il reste <th id="remain"><?php echo "$remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds";?></th>
                       </td>
                       <td>avant l'an : <?php echo $targetDateDisplay; ?>
                       </td>
                     </tr>
               </table>
            </div>
        </div>
        </body>
        </html>
    2. Salut tout le monde.

      Quand je rentre ce code le décompte et fait pour le jour et l'heure à la quelle j'ai modofié le fichier qui le contient... bizarre...
      Merci pour votre aide.