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 :

récupérer la valeur d'une liste déroulante + comparaison de dates


Sujet :

JavaScript

  1. #1
    Futur Membre du Club
    Inscrit en
    Janvier 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 7
    Points : 5
    Points
    5
    Par défaut récupérer la valeur d'une liste déroulante + comparaison de dates
    Bonjour à tous


    Voila j'ai en ce moment même un petit soucis.
    Grâce à ce formulaire j'aimerai pouvoir vérifier que la date de début est bien inférieure à la date de fin

    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
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    		<html>
    		<head>
    		<title>vpsi</title>
    		<script src=script.js></script>
    		</head>
    		<body bgcolor=ivory>
    		<form method=post name="form" action="main.php" onSubmit="return verifSaisie();">
     
    			<table align=center cellspacing=5 border=0>
    			<tr>
    				<td align=right>Type de courbes :</td>
    				<td><select name="graph">
    				<option value=Disques>Disques</option>
    <option value=Cpu>Cpu</option>
    <option value=Network>Network</option>
    				</select></td>
     
    				<td>Nom de la machine :</td>
    				<td><select name="server">
      				<option value=1>machine 1</option>
    <option value=2>machine 2</option>
    				</select></td>
    			</tr>
    			<tr>
    				<td align=right>Date de d&eacute;but :</td>
     
    				<td><select name="day1" id="day11">
      				<option value=1>1</option>
    <option value=2>2</option>
    <option value=3>3</option>
    <option value=4>4</option>
    <option value=5>5</option>
    <option value=6>6</option>
    <option value=7>7</option>
     
    <option value=8>8</option>
    <option value=9>9</option>
    <option value=10>10</option>
    <option value=11>11</option>
    <option value=12>12</option>
    <option value=13>13</option>
    <option value=14>14</option>
    <option value=15>15</option>
    <option value=16>16</option>
     
    <option value=17>17</option>
    <option value=18>18</option>
    <option value=19>19</option>
    <option value=20>20</option>
    <option value=21>21</option>
    <option value=22>22</option>
    <option value=23>23</option>
    <option value=24>24</option>
    <option value=25>25</option>
     
    <option SELECTED value=26>26</option>
    <option value=27>27</option>
    <option value=28>28</option>
    <option value=29>29</option>
    <option value=30>30</option>
    <option value=31>31</option>
    </select>/
            <select name="month1" id="month11">
      				<option value=1>1</option>
     
    <option value=2>2</option>
    <option value=3>3</option>
    <option value=4>4</option>
    <option value=5>5</option>
    <option SELECTED value=6>6</option>
    <option value=7>7</option>
    <option value=8>8</option>
    <option value=9>9</option>
    <option value=10>10</option>
     
    <option value=11>11</option>
    <option value=12>12</option>
    </select>/
            <select name="year1" id="year11">
      				<option SELECTED value=2007>2007</option>
    <option value=2008>2008</option>
    <option value=2009>2009</option>
    <option value=2010>2010</option>
    <option value=2011>2011</option>
     
    <option value=2012>2012</option>
    </select>&nbsp
            <select name="hour1" id="hour11">
      				<option value=0>0</option>
    <option value=1>1</option>
    <option value=2>2</option>
    <option value=3>3</option>
    <option value=4>4</option>
    <option value=5>5</option>
     
    <option value=6>6</option>
    <option value=7>7</option>
    <option value=8>8</option>
    <option value=9>9</option>
    <option value=10>10</option>
    <option value=11>11</option>
    <option value=12>12</option>
    <option value=13>13</option>
    <option SELECTED value=14>14</option>
     
    <option value=15>15</option>
    <option value=16>16</option>
    <option value=17>17</option>
    <option value=18>18</option>
    <option value=19>19</option>
    <option value=20>20</option>
    <option value=21>21</option>
    <option value=22>22</option>
    <option value=23>23</option>
     
    </select>H
            </td>
    				<td align=right>Date de fin :</td>
    				<td><select name="day2" id="day22">
      				<option value=1>1</option>
    <option value=2>2</option>
    <option value=3>3</option>
    <option value=4>4</option>
    <option value=5>5</option>
     
    <option value=6>6</option>
    <option value=7>7</option>
    <option value=8>8</option>
    <option value=9>9</option>
    <option value=10>10</option>
    <option value=11>11</option>
    <option value=12>12</option>
    <option value=13>13</option>
    <option value=14>14</option>
     
    <option value=15>15</option>
    <option value=16>16</option>
    <option value=17>17</option>
    <option value=18>18</option>
    <option value=19>19</option>
    <option value=20>20</option>
    <option value=21>21</option>
    <option value=22>22</option>
    <option value=23>23</option>
     
    <option value=24>24</option>
    <option value=25>25</option>
    <option value=26>26</option>
    <option SELECTED value=27>27</option>
    <option value=28>28</option>
    <option value=29>29</option>
    <option value=30>30</option>
    <option value=31>31</option>
    </select>/
            <select name="month2" id="month22">
     
      				<option value=1>1</option>
    <option value=2>2</option>
    <option value=3>3</option>
    <option value=4>4</option>
    <option value=5>5</option>
    <option SELECTED value=6>6</option>
    <option value=7>7</option>
    <option value=8>8</option>
     
    <option value=9>9</option>
    <option value=10>10</option>
    <option value=11>11</option>
    <option value=12>12</option>
    </select>/
            <select name="year2" id="year22">
      				<option SELECTED value=2007>2007</option>
    <option value=2008>2008</option>
    <option value=2009>2009</option>
     
    <option value=2010>2010</option>
    <option value=2011>2011</option>
    <option value=2012>2012</option>
    </select>&nbsp
            <select name="hour2" id="hour22">
      				<option value=0>0</option>
    <option value=1>1</option>
    <option value=2>2</option>
    <option value=3>3</option>
     
    <option value=4>4</option>
    <option value=5>5</option>
    <option value=6>6</option>
    <option value=7>7</option>
    <option value=8>8</option>
    <option value=9>9</option>
    <option value=10>10</option>
    <option value=11>11</option>
    <option value=12>12</option>
     
    <option value=13>13</option>
    <option SELECTED value=14>14</option>
    <option value=15>15</option>
    <option value=16>16</option>
    <option value=17>17</option>
    <option value=18>18</option>
    <option value=19>19</option>
    <option value=20>20</option>
    <option value=21>21</option>
     
    <option value=22>22</option>
    <option value=23>23</option>
    </select>H
     
    			</tr>
    			<tr>
    				<td align=right>Limite :</td>
    				<td><input type=text name=limit size=25 value="0"></td>
    				<td align=right>Lissage :</td>
    				<td><select name="function">
     
    				<option value=avg>avg</option>
    <option value=max>max</option>
    <option value=min>min</option>
    				</select></td>
    				<!--<td><input type=text name=step size=25 value=1></td>-->
    			</tr>
    			<tr>
    				<td align=right>Inclure :</td>
     
    				<td><input type=text name=in size=25 value=""></td>
    				<td align=right>Exclure :</td>
    				<td><input type=text name=out size=25 value=""></td>
    			</tr>
    			<tr>
    				<td align=right>Echelle min :</td>
    				<td><input type=text name=min size=25 value=""></td>
    				<td align=right>Echelle max :</td>
     
    				<td><input type=text name=max size=25 value=""></td>
    			</tr>
     
    			<tr><td>&nbsp</td>
    			</tr>
    			<tr>
    				<td>&nbsp</td>
    				<td align=right><input type="submit" value="Valider"></td>
    				<td><input type=reset value=Annuler></td>
     
    			</tr>
    			</table>  
    			</form>
            <center>
    		        </center>
    		</body>
    		</html>
    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
    // JavaScript Document
     
    function verifSaisie(){
      var ok;
      var msg = "";
     
      var valeur1 = document.form.limit.value;
      var valeur2 = document.form.min.value;
      var valeur3 = document.form.max.value;
     
      var val2 = parseInt(valeur2);
      var val3 = parseInt(valeur3);
     
      var day_1 = document.getElementById('day11').selectedIndex;
      var month_1 = document.getElementById('month11').selectedIndex;
      var year_1 = document.getElementById('year11').selectedIndex;
      var hour_1 = document.getElementById('hour11').selectedIndex;
     
      var day_2 = document.getElementById('day22').selectedIndex;
      var month_2 = document.getElementById('month22').selectedIndex;
      var year_2 = document.getElementById('year22').selectedIndex;
      var hour_2 = document.getElementById('hour22').selectedIndex;
     
     
      document.getElementById('day11').options[document.getElementById('day11').selectedIndex].value;
      document.getElementById('month11').options[document.getElementById('month11').selectedIndex].value;
      document.getElementById('year11').options[document.getElementById('year11').selectedIndex].value;
      document.getElementById('hour11').options[document.getElementById('hour11').selectedIndex].value;
     
      document.getElementById('day22').options[document.getElementById('day22').selectedIndex].value;
      document.getElementById('month22').options[document.getElementById('month22').selectedIndex].value;
      document.getElementById('year22').options[document.getElementById('year22').selectedIndex].value;
      document.getElementById('hour22').options[document.getElementById('hour22').selectedIndex].value;
     
      alert(year_1);
     
      //date_deb = new Date("12 26, 2007 08:59:58");
      //Nom_de_l_objet = new Date("mois jour, année heures:minutes:secondes")
      //alert(date_deb);
     
      if(isNaN(valeur1)){
        msg += "Limite incorrecte !\n";
        document.form.limit.focus();
      }
     
      if(isNaN(valeur2)||valeur2<0){
        msg += "Echelle min incorrecte !\n";
        document.form.min.focus();
      }
     
      if(isNaN(valeur3)||valeur3<0){
        msg += "Echelle max incorrecte !\n";
        document.form.max.focus();
      }  
     
      if(val2>val3){
        msg += "Echelle min > Echelle max\n";
      }
     
    	if (msg == "") return(true);
    	else	{
    		alert(msg);
    		return(false);    
     }
    }

    quelqu'un aurait il une idée qui puisse me mettre sur la voie ?
    Pb je n'arrive pas à récupérer les valeurs des liste déroulante des dates mais seulemet leur ordre dans la liste


    Merci

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    concatène deux strings aaaammjj puis un simple >=

  3. #3
    Futur Membre du Club
    Inscrit en
    Janvier 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Citation Envoyé par SpaceFrog
    concatène deux strings aaaammjj puis un simple >=
    oui le pb c'est que je n'arrive pas a recuperer les valeurs des listes déroulantes
    je dois avoir une erreur dans mon code javascript

  4. #4
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    et il est ou le javascript ?

  5. #5
    Futur Membre du Club
    Inscrit en
    Janvier 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Citation Envoyé par SpaceFrog
    et il est ou le javascript ?
    excuse moi
    une mauvaise manip

  6. #6
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    oui je me doute, deux fois le html ...
    edite le premier post pour modifer ...

  7. #7
    Futur Membre du Club
    Inscrit en
    Janvier 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Citation Envoyé par SpaceFrog
    oui je me doute, deux fois le html ...
    edite le premier post pour modifer ...
    oui voila c'est fait
    N'hésite pas à me demander des explications sur le code car la je galère vraiment.
    Si tu as des suggestions ou des solutions de remplacement je suis bien sur preuneur

  8. #8
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    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
    <script type='text/javascript'>
    		function verifSaisie(){
    		var hh1=(document.getElementById('hour1').value.length<2)?'0'+document.getElementById('hour1').value:document.getElementById('hour1').value;
    		var jj1=(document.getElementById('day1').value.length<2)?'0'+document.getElementById('day1').value:document.getElementById('day1').value;
    		var mm1=(document.getElementById('month1').value.length<2)?'0'+document.getElementById('month1').value:document.getElementById('month1').value;
    		var aaaa1=document.getElementById('year1').value
     
    		var hh2=(document.getElementById('hour2').value.length<2)?'0'+document.getElementById('hour2').value:document.getElementById('hour2').value;
    		var jj2=(document.getElementById('day2').value.length<2)?'0'+document.getElementById('day2').value:document.getElementById('day2').value;
    		var mm2=(document.getElementById('month2').value.length<2)?'0'+document.getElementById('month2').value:document.getElementById('month2').value;
    		var aaaa2=document.getElementById('year2').value
     
    var ordre=(hh1+jj1+mm1+aaaa1 >hh2+jj2+mm2+aaaa2)?'supérieure':'inférieure';
    alert( 'la date 1 est ' + ordre +' à la date 2') 
    }
     
    		</script>

  9. #9
    Futur Membre du Club
    Inscrit en
    Janvier 2007
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Un GRAND merci a toi pour ta patience et ton aide précieuse
    Sans toi j'en serais toujours au même point.

    Car bien sur ta fonction marche impec.

    Je ferme le post..

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

Discussions similaires

  1. comment récupérer les valeurs d'une liste déroulante
    Par paolo2002 dans le forum Servlets/JSP
    Réponses: 7
    Dernier message: 27/06/2008, 20h05
  2. Récupérer la valeur d'une liste déroulante
    Par Lenezir dans le forum Langage
    Réponses: 6
    Dernier message: 25/01/2008, 16h35
  3. Réponses: 10
    Dernier message: 28/11/2007, 11h12
  4. Réponses: 11
    Dernier message: 26/04/2007, 10h40
  5. récupérer la valeur d'une liste déroulante dynamique
    Par grinder59 dans le forum Général JavaScript
    Réponses: 21
    Dernier message: 23/01/2006, 17h51

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