Affichage des champ d'un formulaire selon une condition (PHP/html)

grimpator Messages postés 4 Date d'inscription mercredi 22 avril 2009 Statut Membre Dernière intervention 23 avril 2009 - 22 avril 2009 à 11:21
Orange73 Messages postés 1375 Date d'inscription dimanche 28 novembre 2004 Statut Membre Dernière intervention 2 août 2011 - 22 avril 2009 à 14:50
Bonjour, mon problème est le suivant:
-j 'ai crée une première liste déroulante contenant les champs: SA, SAS, SARL, URL, SCP...etc
-j'ai ensuite crée une liste déroulante contenant les champs PRIVE , PUBLIC;
-Si le choix s'est porté sur une SA ou une SARL je voudrais qu'il y ait une imposibilité de choisir la nature PUBLIC; (Merci d'avance pour vos réponses)
Voici mon code :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
   <head>
       <title>Fiche_Physique</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
              <link rel="stylesheet" media="screen" type="text/css" title="Design" href="autres.css" />
   </head>
  
 
<form method="post" action="cible_autres.php" >
   
            TITRE



               <select name="titre">
               
            <option value="SA">SA</option>
            <option value="SAS">SAS</option>
            <option value="SARL">SARL</option>
            <option value="URL">URL</option>
            <option value="SCP">SCP</option>
            <option value="SCI">SCI</option>
          
           </select>
          
   

         
        <select name="Nat_jur">
               
                //<option value="PRIVE">PRIVE</option>
                    //<option value="PUBLIC">PUBLIC</option>

            //</select>
  </form>
 
</html>      

1 réponse

Orange73 Messages postés 1375 Date d'inscription dimanche 28 novembre 2004 Statut Membre Dernière intervention 2 août 2011
22 avril 2009 à 14:50
Hello,

utilise javascript.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
   <head>
       <title>Fiche_Physique</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
              <link rel="stylesheet" media="screen" type="text/css" title="Design" href="autres.css" />

<script type="text/javascript">
     function check(pFirst,pName)
     {
         var first = pFirst.titre;
         var result = pFirst.Nat_jur
                if(first.value "SA" || first.value "SARL")
        {
            result.options[1].style.display = "none";
        } else {
            result.options[1].style.display = "block";
        }
     }
</script>

   </head>
  
 
<form method="post" action="cible_autres.php" name="form1" >
   
            TITRE



             <select name="titre" onchange="check(this.form);">
              
            <option value="SA">SA</option>
            <option value="SAS">SAS</option>
            <option value="SARL">SARL</option>
            <option value="URL">URL</option>
            <option value="SCP">SCP</option>
            <option value="SCI">SCI</option>
         
           </select>
         
   

        
        <select name="Nat_jur">
              
        <option value="PRIVE">PRIVE</option>
        <option value="PUBLIC">PUBLIC</option>

        </select>
  </form>
 
</html>

-- Orange73 --
"L'homme n'est pas fait pour travailler, la preuve c'est que cela le fatigue" (Voltaire)
0
Rejoignez-nous