? agir sur un champ en HTML en fonction de la valeur d'un autre champ saisi

Fermé
djoab2021 - 11 juil. 2021 à 16:57
 djoab2021 - 12 juil. 2021 à 10:03
Bonjour,
j'ai un formulaire avec une liste déroulante nommée "mode_sortie" et un autre champ bouton radio nommé "orientation_box". si un bouton de orientation_box est selectionné la liste déroulante doit être inactive.
pour cela, j'ai crée une fonction nommée "getValue()" qui est déclenché on click sur orientation_box mais j'ai le message d'erreur suivant :

Fatal error: Call to undefined function getValue() in C:\wamp\www\Gestion Urgences Medico-Chirurgicaux - Copie\admin\malades\page_medecins.php on line 571

merci d'avance pour votre aide .

voici une partie de mon code HTML :
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>  Modifier le Malade</title> 
		<link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
		<link rel="stylesheet" type="text/css" href="../css/font-awesome.min.css">
		<link rel="stylesheet" type="text/css" href="../css/monStyle.css">
		<link rel="stylesheet" href="../css/jquery-ui-1.10.4.custom.css" >
		<script src="../js/jquery-1.10.2.js"></script>
		<script src="../js/jquery-ui-1.10.4.js"></script> 
		<script src="../js/bootstrap.min.js"></script>  
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
		<!-- <script src="js/jquery-ui-i18n.min.js"></script>-->
       <script>
            function getValue($id_element) {
// Sélectionner l'élément input et récupérer sa valeur
         $valeur = document.getElementById($id_element).value;
         return $valeur;
}    

           function active_det(){
             if ($("#exam[0]").is(":checked")) {
                $('# detail_rx_standard').prop('disabled', false);
               }
             else {
             $('# detail_rx_standard').prop('disabled', 'disabled');
                  }
           }
       
        </script>
    </head>
		
	<body>
	<?php include('../menu.php'); ?>
	<br><br><br>
     <a href="page_lstmal_medecin.php">
                          
           <span class="glyphicon glyphicon-arrow-left"></span>               
           Retour  
            
     </a> 
		<div class="container">
          <div class="panel panel-primary">
				<div class="panel-heading" align="flex">   <font color = "#95B428" size = "5"> (BOX ===>      <?php echo $_SESSION['user']['box'] ?>) </font> </div>
					<div class="panel-body">   
					     <form method="post" action="update_medecins.php" enctype="multipart/form-data">

                            <input type="hidden" name="id_malade" id="id_malade" class="form-control"
										value="<?php echo $le_malade['idmalade']; ?>">
                             
                            <input type="hidden" name="idconsult" id="idconsult" class="form-control"
										value="<?php echo $res_recherche['idconsult']; ?>">

                            <input type="hidden" name="num_consult" id="num_consult" class="form-control" value="<?php echo $res_recherche['num_consult']; ?>">         

                            <input type="hidden" name="idbox" id="idbox" class="form-control" value="<?php echo $box; ?>">   
                             
                            <input type="hidden" name="dated" id="dated" class="form-control" value="<?php echo $dated; ?>">                                    
                             
<!-- *************************************************************-->                              
                           <div class="row my-row">
                            <section>
                             <label for="examen_clinique" class="control-label col-sm-2 text-top"> Examens Cliniques :  </label>
                             <div class="col-sm-4"> 
                                <?php if($_SESSION['user']['box']==1 or $_SESSION['user']['box']==2){?> 
                                <textarea  autofocus name="examen_clinique" id="examen_clinique" cols="50" rows="5" wrap ="on" spellcheck = "false"> 
                                 <?php echo ltrim($res_recherche['examen_clinique']); ?> </textarea>
                                <?php } else { ?>
                                <textarea  name="examen_clinique" id="examen_clinique" cols="140" rows="4"  wrap ="on" spellcheck = "false"> <?php echo $res_recherche['examen_clinique']; ?> </textarea>                                    
                                <?php } ?>    
                                                                                                           
                              </div>
                             
                             <?php if($_SESSION['user']['box']==1 or $_SESSION['user']['box']==2){?>    
                             <label for="traitement_prescrit" class="control-label col-sm-2 text-top"> Traitement prescrit :  </label>
                             <div class="col-sm-4"> 
                                <textarea  name="traitement_prescrit" id="traitement_prescrit" cols="50" rows="5" wrap ="on" spellcheck = "false">
                                <?php echo $res_recherche['traitement_prescrit']; ?> </textarea>                                                
                              </div>
                              <?php } ?> 
                              </section>
                            </div>
                            <div class="row my-row">
                              <section> 
                                 <label for="orientation_box" class="control-label col-sm-2"> Orienter Malade vers  : </label>
                                 <div class="col-sm-4"> 
                                    <div class="radio">
                                  <?php if($_SESSION['user']['box']==1){?> 
                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=2/> BOX 2  </label> <br>

                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=3/> BOX 3 </label>
                                  <?php } ?>  
                                        
                                  <?php if($_SESSION['user']['box']==2){?> 
                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" id="orientation_box" value=3/> BOX 3  </label> <br>
                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" id="orientation_box" value=4/> Radiologie </label> <br>      

                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" id="orientation_box" value=5/> Salle de soins Polyvalente </label> <br>          
                                        
                                      <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" id="orientation_box" value=6/> Salle Observation </label> <br> 
                                        
                                      <label><input type="radio" name="orientation_box" id="orientation_box" value=7/> Déchocage </label>                   
                                        
                                  <?php } ?>  
                                        
                                  <?php if($_SESSION['user']['box']==3){?> 
                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=3/> BOX 2  </label> <br><br>

                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=9/> PU-Chir.Générale </label> <br>      

                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=10/> PU-Chir.Thoracique </label> <br>          
                                        
                                      <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=11/> PU-Chir.Urologiques </label> <br> 
                                        
                                      <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=12/> PU-Neuro-Chirurgie </label> <br><br> 
                                        
                                      <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=13/> Urgences Chir.Maxillo-Faciale </label> <br>      

                                     <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=14/> Urgences Chir.Traumatlogiques </label> <br>          
                                        
                                      <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=15/> Urgences O.R.L </label> <br> 
                                        
                                      <label><input type="radio" onclick="getValue("orientation_box")" name="orientation_box" value=16/> Urgences Ophtalmologiques </label>                                
                                        
                                   <?php } ?>                                          
                                        
                                     </div>
                                  </div>
                    <?php if(getValue("orientation_box") === "") { ?>
                                 
                         <?php if($_SESSION['user']['box']==1 or $_SESSION['user']['box']==2){?> 
                                <label class="control-label col-sm-2"> Sortie  Vers   :</label>
                                <div class="col-sm-4">                        
                                <select class="form-control" name="mode_sortie" id="mode_sortie">
                                   <option value=0>Selectionner un Mode de Sortie </option>       
                                   <option value=1> Domicile </option>
                                </select>
                                </div>
                            <?php } else { ?>
                            <?php if($_SESSION['user']['box']==6 or $_SESSION['user']['box']==7){?> 
                                <label class="control-label col-sm-2"> Sortie  Vers   :</label>
                                <div class="col-sm-4">                        
                                <select class="form-control" name="mode_sortie" id="mode_sortie">
                                       <option value=0>Selectionner un Mode de Sortie                                    
                                       <?php foreach ($mode_sortie as $mod_sort) { ?>
                                       <option value="<?php echo $mod_sort['id'] ?>" <?php if($le_malade['mode_sortie']===$mod_sort['id']) echo "selected" ?>>
                                       <?php echo $mod_sort['mode_sortie'] ?>
                                    <?php } ?>       
                                       </option>
                                </select>
                                </div>                                                            
                            <?php } ?>                                                         
                                  
                            <?php } ?>
                        <?php } ?> 
                              </section>
                            </div>
                             
       	    <button type="submit" class="btn btn-success" display:inline-block>
                            <span class="glyphicon glyphicon-save"></span>
                            
                     Enregistrer
            </button> 
                   
            <button type="reset" class="btn btn-success" display:inline-block>
                       <span class="glyphicon glyphicon-remove"></span>
                            
                       Annuler
            </button> 
                            
                        </form>	
					</div>
          </div>            
		</div>     
	</body>
</html>


Configuration: Windows / Firefox 89.0

3 réponses

jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 4 649
11 juil. 2021 à 17:47
Bonjour
Ta fonction getValue ... C'est du JavaScript pas du PHP.
0
Merci pour l'information.
Comme je suis débutant en developpement web, peux tu m'indiquer comment je dois utiliser cette fonction en JavaScript ?
0
ou encore mieux, comment utiliser une fonction similaire en php ?
0