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 :

Utilisation des tableaux, ne récupère qu'une colonne sur quatre


Sujet :

JavaScript

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2014
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2014
    Messages : 3
    Points : 3
    Points
    3
    Par défaut Utilisation des tableaux, ne récupère qu'une colonne sur quatre
    Bonjour, bonsoir a tous j'ai un soucis mon programme ne récupère qu'une colonne sur quatre a l'affichage. Une grosse faute doit être écrite ou une petite ligne manquante, je ne sais pas je ne vois pas du tout.. Je vous ai copiez-colez le code source de mon programme qui est écrit en JS à l'aide de Smultron (Logiciel pour MacBook Pro). Merci de vos réponses.

    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
    <html>
        <head>
            <title> Programme Pour L'Utilisation Des Tableaux. </title>
    <style type="text/css">
    				body { background-image:url(http://coquelico.c.o.pic.centerblog.net/tumblr_mccykozhfe1r4zr2vo1_500.gif);
                	background-attachment:fixed; background-repeat:no-repeat;
                	background-position:left top; background-size:cover; }
                	</style>
     
     
            <script language="javascript">
     
     var colonne0=new Array; colonne0[0]="1986"; colonne0[1]="Sergueï Bubka"; colonne0[2]="Moscou"; colonne0[3]="6,01"; colonne0[4]="";
     var colonne1=new Array; colonne1[0]="1987"; colonne1[1]="Sergueï Bubka"; colonne1[2]="Prague"; colonne1[3]="6,03"; colonne1[4]="";
     var colonne2=new Array; colonne2[0]="1988"; colonne2[1]="Sergueï Bubka"; colonne2[2]="Nice"; colonne2[3]="6,06"; colonne2[4]="";
     var colonne3=new Array; colonne3[0]="1989"; colonne3[1]="Sergueï Bubka"; colonne3[2]="Nice"; colonne3[3]="6,06"; colonne3[4]=""; 
     var colonne4=new Array; colonne4[0]="1990"; colonne4[1]="Sergueï Bubka"; colonne4[2]="Nice"; colonne4[3]="6,06"; colonne4[4]=""; 
     var colonne5=new Array; colonne5[0]="1991"; colonne5[1]="Sergueï Bubka"; colonne5[2]="Malmö"; colonne5[3]="6,10"; colonne5[4]=""; 
     var colonne6=new Array; colonne6[0]="1992"; colonne6[1]="Sergueï Bubka"; colonne6[2]="Tokyo"; colonne6[3]="6,13"; colonne6[4]=""; 
     var colonne7=new Array; colonne7[0]="1993"; colonne7[1]="Sergueï Bubka"; colonne7[2]="Londres"; colonne7[3]="6,05"; colonne7[4]=""; 
     var colonne8=new Array; colonne8[0]="1994"; colonne8[1]="Sergueï Bubka"; colonne8[2]="Sestrière"; colonne8[3]="6,14"; colonne8[4]=""; 
     var colonne9=new Array; colonne9[0]="1995"; colonne9[1]="Okkert Brits"; colonne9[2]="Cologne"; colonne9[3]="6,03"; colonne9[4]=""; 
     var colonne10=new Array; colonne10[0]="1996"; colonne10[1]="Sergueï Bubka"; colonne10[2]="Atlanta"; colonne10[3]="6,02"; colonne10[4]="";
     var colonne11=new Array; colonne11[0]="1997"; colonne11[1]="Sergueï Bubka"; colonne11[2]="Fukuoka"; colonne11[3]=""; colonne11[4]=""; 
     var colonne12=new Array; colonne12[0]="1998"; colonne12[1]="Jeff Hartwig"; colonne12[2]="Uniondale"; colonne12[3]=""; colonne12[4]="";
     var colonne13=new Array; colonne13[0]="1999"; colonne13[1]="Maksim Tarasov"; colonne13[2]="Athènes"; colonne13[3]=""; colonne13[4]="";
     var colonne14=new Array; colonne14[0]="2000"; colonne14[1]="Jeff Hartwig"; colonne14[2]="Johannesburg"; colonne14[3]=""; colonne14[4]="";
     var colonne15=new Array; colonne15[0]="2001"; colonne15[1]="Dmitri Markov"; colonne15[2]="Edmonton"; colonne15[3]=""; colonne15[4]="";
     var colonne16=new Array; colonne16[0]="2002"; colonne16[1]="Dmitri Markov"; colonne16[2]="Edmonton"; colonne16[3]=""; colonne16[4]="";
     var colonne17=new Array; colonne17[0]="2003"; colonne17[1]="Dmitri Markov"; colonne17[2]="Edmonton"; colonne17[3]=""; colonne17[4]="";
     var colonne18=new Array; colonne18[0]="2004"; colonne18[1]="Timothy Mack"; colonne18[2]="Monaco"; colonne18[3]=""; colonne18[4]="";
     var colonne19=new Array; colonne19[0]="2005"; colonne19[1]="Timothy Mack"; colonne19[2]="Monaco"; colonne19[3]=""; colonne19[4]="";
     var colonne20=new Array; colonne20[0]="2006"; colonne20[1]="Timothy Mack"; colonne20[2]="Monaco"; colonne20[3]=""; colonne20[4]="";
     var colonne21=new Array; colonne21[0]="2007"; colonne21[1]="Timothy Mack"; colonne21[2]="Monaco"; colonne21[3]=""; colonne21[4]="";
     var colonne22=new Array; colonne22[0]="2008"; colonne22[1]="Evgeniy Luckyanenko"; colonne22[2]="Bydgoszcz"; colonne22[3]=""; colonne22[4]="";
     var colonne23=new Array; colonne23[0]="2009"; colonne23[1]="Renaud Lavillenie"; colonne23[2]="Leiria"; colonne23[3]=""; colonne23[4]=""; 
     var colonne24=new Array; colonne24[0]="2010"; colonne24[1]="Renaud Lavillenie"; colonne24[2]="Leiria"; colonne24[3]=""; colonne24[4]="";
     var colonne25=new Array; colonne25[0]="2011"; colonne25[1]="Renaud Lavillenie"; colonne25[2]="Leiria"; colonne25[3]=""; colonne25[4]="";
     var colonne26=new Array; colonne26[0]="2012"; colonne26[1]="Björn Otto"; colonne26[2]="Aix-la-Chapelle"; colonne26[3]=""; colonne26[4]="";
     var colonne27=new Array; colonne27[0]="2013"; colonne27[1]="Renaud Lavillenie"; colonne27[2]="Londres"; colonne27[3]=""; colonne27[4]="";
     
    var Tableau=new Array; Tableau[0]=colonne0; Tableau[1]=colonne1; Tableau[2]=colonne2; Tableau[3]=colonne3; Tableau[4]=colonne4; 							Tableau[5]=colonne5; Tableau[6]=colonne6; Tableau[7]=colonne7; Tableau[8]=colonne8; Tableau[9]=colonne9; 
            Tableau[10]=colonne10; Tableau[11]=colonne11; Tableau[12]=colonne12; Tableau[13]=colonne13; Tableau[14]=colonne14; Tableau[15]=colonne15; 			Tableau[16]=colonne16; Tableau[17]=colonne17; Tableau[18]=colonne18; Tableau[19]=colonne19; Tableau[20]=colonne20; Tableau[21]=colonne21; 			Tableau[22]=colonne22; Tableau[23]=colonne23; Tableau[24]=colonne24; Tableau[25]=colonne25; Tableau[26]=colonne26; Tableau[27]=colonne27; 
     
     
     
            function Chercher()
                     {
                     var DATE = document.forms.FORMULAIRE.DATE.value;
                     var i=0;
                     while(i<28)
                         {
                         if(Tableau[i][0]==DATE)
                            {
                             document.forms.FORMULAIRE.ATHLETE.value= Tableau[i][1];
                             document.forms.FORMULAIRE.lIEU.value= Tableau[i][2];
                             document.forms.FORMULAIRE.NATIONALITE.value= Tableau[i][3];
                             document.forms.FORMULAIRE.HAUTEUR.value= Tableau[i][4];
                            }
                         i=i+1;
                         }
                     }
     
            </script>
     
      <body>
          <div align=center>
          <Font color="green" size="10"><b> Record de saut à la perche depuis 1986 </b></Font>
          	<BR><BR>
            <FORM name="FORMULAIRE">
            <Font color="Purple" size="5"><b>Choisissez une années <b></Font>
          	<BR><BR>
            <SELECT name="DATE"><option selected>1986</option>
            							  <option>1987</option>
                                          <option>1988</option>
                                    	  <option>1989</option>
                                    	  <option>1990</option>
                                    	  <option>1991</option>
                                    	  <option>1992</option>
                                    	  <option>1993</option>
                                    	  <option>1994</option>
                                    	  <option>1995</option>
                                    	  <option>1996</option>
                             	       	  <option>1997</option>
                                	      <option>1998</option>
                                	      <option>1999</option>
                              	          <option>2000</option>
                               	          <option>2001</option>
                                    	  <option>2002</option>
                                    	  <option>2003</option>
                                    	  <option>2004</option>
                                    	  <option>2005</option>
                                    	  <option>2006</option>
                                    	  <option>2007</option>
                                    	  <option>2008</option>
                                    	  <option>2009</option>
                                    	  <option>2010</option>
                                    	  <option>2011</option>
                                    	  <option>2012</option>
                                    	  <option>2013</option>
            </SELECT>
     
            <BR><BR><BR><BR>
            <input type="button" value="Let's Go ! " style="WIDTH : 100px; HEIGHT : 40px"  onClick="Chercher()">
            <BR><BR><BR><BR>
    			        <Font color="green" size="5"><b> Athlète <b></Font>
            <input type="text" name="ATHLETE" size="50">
            <BR><BR>
            <Font color="blue" size="5"><b>Lieu<b></Font>
            <input type="text" name="LIEU" size="50">
            <BR><BR>
            <Font color="yellow" size="5"><b>National<b></Font>
            <input type="text" name="NATIONALITE" size="50">
            <BR><BR>
            <Font color="purple" size="5"><b> Hauteur <b></Font>
            <input type="text" name="HAUTEUR" size="50">
            </FORM>
            <BR><BR><BR><BR>
    		<address>Batti Mondoloni © 2014</address>
          </div>
     
        </body>

  2. #2
    Rédacteur/Modérateur

    Avatar de SylvainPV
    Profil pro
    Inscrit en
    Novembre 2012
    Messages
    3 375
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 3 375
    Points : 9 944
    Points
    9 944
    Par défaut
    aïe mes yeux !

    Avant de songer à se pencher sur le bug, il faut absolument revoir ton code :
    - externaliser le CSS et le JS dans des fichiers à part
    - plus d'attribut language pour les balises scripts
    - la déclaration d'Array, il faut à tout prix virer cet immonde bloc déclaratif. Voilà comment on déclare un tableau 2D sans s'arracher les cheveux :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    var Tableau = [ 
    [1986, "Sergueï Bubka", "Moscou", "6,01", ""],
    [1987, "Sergueï Bubka", "Prague", "6,03", ""],
    ...
    ];
    - pas de balises <font>, passer par CSS
    - mettre toutes les balises en minsucule
    - plus d'attribut align sur les div
    - ne pas se servir des <br> pour définir des marges, passer par CSS

    ça ne résout pas ton problème, mais au moins on y verra bien plus clair
    One Web to rule them all

  3. #3
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2014
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2014
    Messages : 3
    Points : 3
    Points
    3
    Par défaut
    Merci pour les astuces, mais le professeur que l'on a nous dit de faire comme ça alors que l'on peu faire plus simple.. Je n'arrive du tout a voir l'erreur... Lorsque je le test il me met juste le nom mais aucuns autres trucs, certes mon tableau n'est pas totalement remplie, mais il pourrais afficher au moins la premières colonnes... C'est un devoir qui est a rendre avant dimanche soir 8h.

    Merci de vos réponses

  4. #4
    Rédacteur/Modérateur

    Avatar de SylvainPV
    Profil pro
    Inscrit en
    Novembre 2012
    Messages
    3 375
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 3 375
    Points : 9 944
    Points
    9 944
    Par défaut
    Oublie ton prof, tu travailles pour toi-même.

    Tu as mis un l minuscule à lieu dans la fonction Checher. Apprend à te servir du debugger, ça m'a pris 1 minute pour trouver avec l'erreur

    http://jsbin.com/fuyewedehe/1/edit?html,console,output
    One Web to rule them all

  5. #5
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2014
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2014
    Messages : 3
    Points : 3
    Points
    3
    Par défaut
    A d'accord !!! Merci bien je commence juste dans la programmation tu peu m'expliquer ce qu'est le debugger ?

  6. #6
    Rédacteur/Modérateur

    Avatar de SylvainPV
    Profil pro
    Inscrit en
    Novembre 2012
    Messages
    3 375
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 3 375
    Points : 9 944
    Points
    9 944
    One Web to rule them all

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

Discussions similaires

  1. utiliser des tableaux dans une class
    Par artemis93 dans le forum Débuter avec Java
    Réponses: 3
    Dernier message: 24/04/2011, 11h45
  2. Réponses: 1
    Dernier message: 12/12/2007, 13h46
  3. Réponses: 4
    Dernier message: 10/05/2006, 10h36
  4. [TDrawGrid]Comment afficher une colonne sur quatre ?
    Par Laurent Dardenne dans le forum Composants VCL
    Réponses: 5
    Dernier message: 11/02/2006, 16h42
  5. Concaténer des lignes d'enregistrements dans une colonne
    Par dany13 dans le forum MS SQL Server
    Réponses: 10
    Dernier message: 08/07/2005, 21h56

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