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 :

choix pour liste deroulante liée


Sujet :

Langage PHP

  1. #1
    Futur Membre du Club
    Femme Profil pro
    Développeur informatique
    Inscrit en
    Août 2014
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 35
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Août 2014
    Messages : 13
    Points : 8
    Points
    8
    Par défaut choix pour liste deroulante liée
    Bonjour tout le monde,

    j'ai un soucis que je n'arrive pas à résoudre ça fait pas mal de temps et je souhaiterai votre aide .

    J'ai 3 liste déroulante liés Servicesniveau1 - Servicesniveau2 et Servicesniveau3

    Si je selectione dans la liste deroulante Servicesniveau1 une valeur et que j'envoie sa fonctionne jusque la pas de souci.
    par contre mon probléme et que si je selectionne dans la liste deroulante Servicesniveau1 une valeur et dans la liste deroulante Servicesniveau2 une valeur et que j'envoie il recupere la valeur de la liste deroulante Servicesniveau1.
    Ce que jaimerai faire c'est qu'il recupere la valeur de la derniere liste deroulante selectionné.

    merci aux personnes qui pourront m'aider.
    code javascript
    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
     
    <script language="javascript">
    function EnvoyerFormulaire()	{			  
    		var form_valid = true ;				
    	 	message = " <?php   $mess->printString("template.erreur") ?>\n\n";     
    	 	if  (document.Frm_MAJPoste.libelle_FR.value == '') {
    	         form_valid = false ;
    	         message += "- <?php   echo $mess->getString("poste.lib") ?> \n\n";
    	 	}
    	 	if  (document.Frm_MAJPoste.service.value == '0') {
    	         form_valid = false ;
    	         message += "- <?php   echo $mess->getString("poste.service") ?> \n\n";
    	 	}
    	 	if  (document.Frm_MAJPoste.rem_fct.value == '0') {
    	         form_valid = false ;
    	         message += "- <?php   echo $mess->getString("poste.zonerem") ?> \n\n";
    	 	}
     
    		if (!form_valid) {
    			alert(message) ;
    		} else	{
    			document.Frm_MAJPoste.submit() ;
    		}
    	}
    </script>


    liste déroulante
    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
     
              <table width="100%" border="0" align="left" align="center">					         							  
                   		     <tr>
                                             	<td nowrap class="Libelle" align="left"><?php   $mess->printString("user.service") ?> : </td>
                                             	<td>                                          
                                                 	<select name="service" size="1" class="Controle_Plat_Obligatoire_EA" style="width:250px" OnChange="change_service()" >
     
    	                                                   <?php     if ($service_datas[0][POSTE_SERVICE] == 0 ) { ?><option value="0">Sélectionnez le service ...	<?php    } ?>
    <?php                                                   for ($i = 0 ; $i < sizeof($service_datas) ; $i++)    {?>                                            
                                                            	<option value="<?php  echo $service_datas[$i][BU_CODE]?>"><?php  echo $service_datas[$i][BU_LIB]?>
    <?php                                                 	}	?>
                                                 	</select>
                                             	</td>          
                                             </tr>
    										<tr>
                                             	<td nowrap class="Libelle" align="left"><?php   $mess->printString("user.poste1"); ?> : </td>
                                             	<td>                                          
                                                 	<select id="service_niveau1" name="service_niveau1" size="1" class="Controle_Plat_Obligatoire_EA" style="width:250px" OnChange="change_service2()" >
    														<option value="0" >Sélectionnez la service niveau 1 ...                                 
                                                	</select>
                                             	</td>											
    </tr>
    										<tr>
                                             	<td nowrap class="Libelle" align="left"><?php   $mess->printString("user.poste2"); ?> : </td>
                                             	<td>                                          
                                                 	<select id="service_niveau2" name="service_niveau2" size="1" class="Controle_Plat_Obligatoire_EA" style="width:250px" OnChange="change_service3()">
    														<option value="0" >Sélectionnez la service Niveau 2 ...                                    
                                                 	</select>
                                             	</td>
    										</tr>
                                            <tr>
                                             	<td colspan="2" class="Libelle" align="left"><font color="CC6600" ><?php   $mess->printString("poste.rem1"); ?></font></td>
                                            </tr>
                                            <tr>
                                             	<td nowrap class="Libelle" align="left"><?php   $mess->printString("poste.rem2"); ?> : </td>
                                             	<td>                                          
                                                 	<select name="rem_fct" size="1" class="Controle_Plat_Obligatoire_EA">
    <?php                                              if ($datas[0][POSTE_REM] == 0 ) { ?><option value="0" <?php   if ($_POST[tri_bu]) echo "selected"?>><?php  echo $mess->getString("poste.trilib");	  }?>
    <?php                                              if ($datas[0][POSTE_REM] <> 0 ) { ?><option value="0" ><?php  echo $mess->getString("poste.trilib");	  } ?>
                                                       <option value="01"<?php  if ($datas[0][POSTE_REM] == "01") echo "selected"?>><?php  $mess->printString("poste.dir")	?>
                                                       <option value="02"<?php  if ($datas[0][POSTE_REM] == "02") echo "selected"?>><?php  $mess->printString("poste.diri")	?>
                                                       <option value="99"<?php  if ($datas[0][POSTE_REM] == "99") echo "selected"?>><?php  $mess->printString("poste.pasdir")	?>
                                                   </select>
                                             	</td>
                                            </tr>
                   						  <tr height="20">
                   							  <td nowrap class="Libelle" align="left"></td>
                   						  </tr>
    <?php /*	?>
                   						  <tr>
                   							  <td nowrap class="Libelle" align="left"><?php   $mess->printString("poste.inactif")?></td>
                   							  <td>
                   							      <input type="checkbox" align="center" name="inactif" value="1" <?php  if ($datas[0][POSTE_INACTIF]) echo "checked"?>>
                   							  </td>
                   						  </tr>
    <?php */	?>
    <?php								 if ($action != "save") { ?>
    			                                <tr id="util" align="center" bgcolor="#FFFFFF">		  
    					    			             <td colspan="2">
    									             	<table width="100%" cellspacing="0" class="bg_O1_int"  border="0" cellpadding="0" border="0">
    														<tr>
    			                           						<td align="center"  width="100%" class="Libelle_H"><?php   $mess->printString("poste.listefil"); ?></td>
    			                              					<td id="cre_util" align="left" valign="center">
    			                                 					<a href="../Pages/Fonction_Profils.php?action2=<?php  echo $action ?>&maj=<?php  echo $maj?>&code=<?php  echo $code ?>&fil_sel=<?php  echo $fil_sel ?>&user_sel=<?php  echo $user_sel ?>&prof_sel=<?php  echo $prof_sel ?>">
    			                                 						<img src="../images/Btn_MAJ.gif" alt="Rattachement Fonction / Profil" border="0" >
    			                                 					</a>
    			                              					</td>               								
    			                           					</tr>
    			                           					<tr>
    			                           						<td colspan="2">
    			                           							<table width="100%" cellspacing="0" class="bg_O1_int"  border="0" cellpadding="0" border="0">											  					 							
    <?php                                         						$color[0] = "#FFFFFF" ;
    			                                         				$color[1] = "#EAEAEA" ; ?>
    <?php                                          						for ($i = 0 ; $i < sizeof($fil_datas) ; $i++)	{?>
    			                                         					<tr>
    			                                               					<td align="left" valign="middle" bgcolor="<?echo $color[$i%2]?>" class="Ligne"><?echo $fil_datas[$i][PROFIL_LIBELLE]?></td>
    			                                               				</tr>
    <?php                                          						}   ?> 
    			                           							</table>
    			                           						</td>
    			                           					</tr>            						                                  						                    
    									             	</table>
    									             </td>
    									         </tr>
    			                                <tr height="30" align="center" bgcolor="#FFFFFF">
    			                                	<td>
    			                                	</td>
    			                                </tr>
    			                                <tr id="ug" align="center" bgcolor="#FFFFFF">
    					    			             <td colspan="2">
    									             	<table width="50%" cellspacing="0" class="bg_O1_int"  border="0" cellpadding="0" border="0">
    														<tr>
    			                           						<td align="center"  width="100%" class="Libelle_H"><?php   $mess->printString("service.listug"); ?></td>
    			                              					<td align="left" valign="center">
    			                                 					<a href="../Pages/fonction_ug.php?action2=<?php  echo $action ?>&maj=<?php  echo $maj?>&code=<?php  echo $code ?>&service_sel=<?php  echo $service_sel ?>">
    			                                 						<img src="../images/Btn_MAJ.gif" alt="Rattachement UG / fonctionr" border="0" >
    			                                 					</a>
    			                              					</td>               								
    			                           					</tr>
    			                           					<tr>
    			                           						<td colspan="2">
    			                           							<table width="100%" cellspacing="0" class="bg_O1_int"  border="0" cellpadding="0" border="0">											  					 							
    <?php                                         						$color[0] = "#FFFFFF" ;
    			                                         				$color[1] = "#EAEAEA" ; ?>
    <?php                                          						for ($i = 0 ; $i < sizeof($fil_datas_ug) ; $i++)	{?>
    			                                         					<tr>                                  							   
    			                                               					<td align="center" valign="middle" bgcolor="<?echo $color[$i%2]?>" class="Ligne"><b><?echo $fil_datas_ug[$i][UG_LIB]?></b></td>
    			                                               				</tr>
    <?php                                          						}   ?> 
    			                           							</table>
    			                           						</td>
    			                           					</tr>            						                                  						                    
    									             	</table>
    									             </td>
    									         </tr>
    <?php								} ?>
                			         </table>					
       					         </td>
       				         </tr>
       				      </table>

  2. #2
    Futur Membre du Club
    Femme Profil pro
    Développeur informatique
    Inscrit en
    Août 2014
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 35
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Août 2014
    Messages : 13
    Points : 8
    Points
    8
    Par défaut
    Bonjour
    Quelqu’un pourrait-il m'aider à finir de traduire cet algo en langage JavaScript svp

    algo

    Si la liste déroulante n°3 est selectionnée
    {
    alors récupére valeur liste déroulante n°3
    }
    sinon
    {
    si la liste déroulante n°2 est selectionnée
    {
    alors récupére valeur liste déroulante n°2
    }
    sinon
    {
    alors récupére valeur liste déroulante n°1
    }
    }

    return valeur


    Pour récupérer la valeur de la liste déroulante pas de souci mais mon problème c'est le "s'il est sélectionnée"

    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
     
    	var valeur = 0;
     
    	if (document.form.liste_deroulante-3.value != '0')
    	{
    		valeur = document.form.liste_deroulante-3.value ;
    	}
    	else
    	{
    		if (document.form.liste_deroulante-2.value != '0')
    		{
    			valeur = document.form.liste_deroulante-2.value;
    		}
    		else
    		{
    			valeur = document.form.liste_deroulante-1.value;
    		}
     
    	}
                  // return valeur

Discussions similaires

  1. Deux listes deroulantes liées entre elles
    Par killerhertz dans le forum ASP
    Réponses: 4
    Dernier message: 16/07/2006, 22h43
  2. Raccourci clavier pour liste déroulante
    Par enguerran dans le forum Balisage (X)HTML et validation W3C
    Réponses: 7
    Dernier message: 17/05/2006, 04h53
  3. [VBA] Pas de choix dans liste deroulante = ALL
    Par hugo69 dans le forum Access
    Réponses: 4
    Dernier message: 04/05/2006, 12h03
  4. [AJAX] listes deroulantes liées x3
    Par Tempotpo dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 20/04/2006, 16h55
  5. Lecture choix dans liste deroulante
    Par angelevil dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 15/03/2006, 16h20

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