Partage
  • Partager sur Facebook
  • Partager sur Twitter

Plusieurs comptes à rebours

    20 décembre 2005 à 22:51:09

    Bonjour!
    J'ai un probleme :
    ma page est en deux parties, la premiere, celle du haut possede un compte a rebours toujours actif, et la partie du bas, qui varie, possede des fois un compte à rebours. Je créé donc, deux fonctions, et ma page est au final organisée comme cela :
    <html>
    <head>fonction 1</head>
    <body onLoad='la fonction1'>
    Ma page avec la fonction 1 qui ajoute un certain nombre toutes les secondes
    </body>
    <head>la fonction compte a rebours a partir d'un certain nombre</head>
    <body onLoad='fonction compte a rebours'>
    La deuxieme partie avec un compte a rebours
    </body>
    </html>

    La premiere fonction marche correctement, mais pas la 2e.
    Je sais que j'ai plusieur body, et plusieur head, mais je vois pas comment faire autrement.
    Est-ce que quelqu'un pourrait m'aider?
    Merci
    • Partager sur Facebook
    • Partager sur Twitter
      21 décembre 2005 à 0:10:32

      Salut!

      Je te déconseille fortement de faire ce que tu fais en ce moment avec 2 head et 2 body... Je te conseille plutôt d'utiliser soit un tableau(<table></table>), ou sinon les feuilles de style(CSS <style></style>)

      Je sais pas à quoi ressemble ta page, mais tu peux essayer quelque chose de même:

      <html>
              <head>
              <title>Titre de ta page de compte a rebour</title>
              </head>
      <body>
      <table border="1" width="75%" align="center">
              <tr>
                      <td height="200px">PREMIERE FONCTION(au lieu de ton premier body)</td>
              <tr>
              <tr>
                      <td height="500px">DEUXIEME FONCTION(au lieu de ton 2e body)</td>
              </tr>
      </table>
      </body>
      </html>


      Envois-nous tes fonctions si tu veux qu'on t'aide pour les inscruster dans le code
      Bonne chance! ;)
      Thom
      PS: Si tu cherches des info pour construire tes pages, tu peux aller là:
      http://www.siteduzero.com/tuto-3-6-0-apprenez-a-creer-votre-site-web.html ;):p
      • Partager sur Facebook
      • Partager sur Twitter
        21 décembre 2005 à 8:30:57

        Je peux pas faire ça, le probleme, c'est que en fait, c'est 2 pages completement différentes que j'inclus dans une meme page a l'aide du PHP.
        Niveau PHP et HTML j'ai pas de soucie, mais niveau JavaScript ... C'est pas encore ça!
        En fait dans la premiere page je doit inclure cette fonction :

        function metal(new_metal)
        {
                var new_metal=new_metal+(<?echo $production['metal'];?> / 3600);
                var metal_arrondi=Math.round(new_metal);
                document.ressources.metal.title=metal_arrondi + " M";
                if(metal_arrondi<1000)
                {
                        document.ressources.metal.value=Math.round(new_metal) + " M";
                }
                if(metal_arrondi>=1000 && metal_arrondi<1000000)
                {
                        var metal_arrondi2=Math.round(metal_arrondi/1000);
                        document.ressources.metal.value=metal_arrondi2 + " kM";
                }
                if(metal_arrondi>=1000000 && metal_arrondi<1000000000)
                {
                        var metal_arrondi2=Math.round(metal_arrondi/1000000);
                        document.ressources.metal.value=metal_arrondi2 + " MM";
                }
                if(metal_arrondi>=1000000000)
                {
                        var metal_arrondi2=Math.round(metal_arrondi/1000000000);
                        document.ressources.metal.value=metal_arrondi2 + " GM";
                }
                setTimeout("metal("+new_metal+";)",1000);
        }


        Et dans la 2e celle la :

        <!--
        var time_restant<?echo $action;?>=<?echo $time_restant;?>;
        function <?echo $action;?>()
        {
                time_restant<?echo $action;?>--;
                if(time_restant<?echo $action;?><60)
                {                     
                        if(time_restant<?echo $action;?><0)
                        {
                                var restant<?echo $action;?> = 'Terminé !';
                        }
                        else
                        {
                                var restant<?echo $action;?>=time_restant<?echo $action;?> + ' secondes restantes';
                        }
                }
                if((time_restant<?echo $action;?>>=60) && (time_restant<?echo $action;?><3600))
                {
                        var minutes_virg_sec<?echo $action;?> = time_restant<?echo $action;?> / 60;
                        var minutes<?echo $action;?> = Math.floor(minutes_virg_sec<?echo $action;?>);
                        var secondes<?echo $action;?> = time_restant<?echo $action;?> - minutes<?echo $action;?> * 60;
                       
                        if((secondes<?echo $action;?><10) && (secondes<?echo $action;?>>=0))
                        {
                                var rest<?echo $action;?> = '0' + secondes<?echo $action;?>;
                                var secondes<?echo $action;?> = rest<?echo $action;?>;
                        }
                       
                        var restant<?echo $action;?>= minutes<?echo $action;?> + ' minutes ' + secondes<?echo $action;?> + ' secondes restantes'
                }
                if((time_restant<?echo $action;?>>=3600) && (time_restant<?echo $action;?><86400))
                {
                        var minutes_virg_sec<?echo $action;?> = time_restant<?echo $action;?> / 60;
                        var minutes<?echo $action;?> = Math.floor(minutes_virg_sec<?echo $action;?>);
                        var secondes<?echo $action;?> = time_restant<?echo $action;?> - minutes<?echo $action;?> * 60;
                       
                        if((secondes<?echo $action;?><10) && (secondes<?echo $action;?>>=0))
                        {
                                var rest<?echo $action;?> = '0' + secondes<?echo $action;?>;
                                var secondes<?echo $action;?> = rest<?echo $action;?>;
                        }
                       
                        var heures_virg_sec<?echo $action;?> = minutes<?echo $action;?> / 60;
                        var heures<?echo $action;?> = Math.floor(heures_virg_sec<?echo $action;?>);
                        var minutes<?echo $action;?> = minutes<?echo $action;?> - heures<?echo $action;?> * 60;
                       
                        if((minutes<?echo $action;?><10) && (minutes<?echo $action;?>>=0))
                        {
                                var rest<?echo $action;?> = '0' + minutes<?echo $action;?>;
                                var minutes<?echo $action;?> = rest<?echo $action;?>;
                        }
                       
                        var restant<?echo $action;?>= heures<?echo $action;?> + ' h ' + minutes<?echo $action;?> + ' min ' + secondes<?echo $action;?> + ' sec restantes'
                }
                if(time_restant<?echo $action;?>>=86400)
                {
                        var minutes_virg_sec<?echo $action;?> = time_restant<?echo $action;?> / 60;
                        var minutes<?echo $action;?> = Math.floor(minutes_virg_sec<?echo $action;?>);
                        var secondes<?echo $action;?> = time_restant<?echo $action;?> - minutes<?echo $action;?> * 60;
                       
                        if((secondes<?echo $action;?><10) && (secondes<?echo $action;?>>=0))
                        {
                                var rest<?echo $action;?> = '0' + secondes<?echo $action;?>;
                                var secondes<?echo $action;?> = rest<?echo $action;?>;
                        }
                       
                        var heures_virg_sec<?echo $action;?> = minutes<?echo $action;?> / 60;
                        var heures<?echo $action;?> = Math.floor(heures_virg_sec<?echo $action;?>);
                        var minutes<?echo $action;?> = minutes - heures<?echo $action;?> * 60;
                       
                        if((minutes<?echo $action;?><10) && (minutes<?echo $action;?>>=0))
                        {
                                var rest<?echo $action;?> = '0' + minutes<?echo $action;?>;
                                var minutes<?echo $action;?> = rest<?echo $action;?>;
                        }
                       
                        var jours_virg_sec<?echo $action;?> = heures<?echo $action;?> / 24;
                        var jours<?echo $action;?> = Math.floor(jours_virg_sec<?echo $action;?>);
                        var heures<?echo $action;?> = heures<?echo $action;?> - jours<?echo $action;?> * 24;
                       
                        if((heures<?echo $action;?><10) && (heures<?echo $action;?>>=0))
                        {
                                var rest<?echo $action;?> = '0' + heures<?echo $action;?>;
                                var heures<?echo $action;?> = rest<?echo $action;?>;
                        }
                       
                        var restant<?echo $action;?>= jours<?echo $action;?> + ' j ' + heures<?echo $action;?> + ' h ' + minutes<?echo $action;?> + ' min ' + secondes<?echo $action;?> + ' sec restantes'
                }
                var restant_fin<?echo $action;?> = '<?echo $act_aff;?>' + ' : ' + restant<?echo $action;?>;
                document.<?echo $action;?>1.<?echo $action;?>.value=restant_fin<?echo $action;?>;
                setTimeout("<?echo $action;?>()",1000);
        }
        // -->
        </script>


        Et pour les faire fonctionner, d'après ce que j'ai compris, je suis obliger de les mettre dans le header, et de les appeler grace à onLoad dans un body.
        ma structure est a peut-près comme cela :
        page :
        <html>
        <body>
        <div>partie 1</div>
        <div>partie 2</div>
        </body>
        </html>
        partie 1:
        Ben il faut que j'arrive a faire executer la foncion 1

        partie 2:
        il faut que j'execute la deuxieme fonction, mais je ne peux la générer qu'ici, car elle contient des données que l'on connait seulement à ce moment la .

        • Partager sur Facebook
        • Partager sur Twitter

        Plusieurs comptes à rebours

        × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
        × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
        • Editeur
        • Markdown