11484 sujets

JavaScript, DOM et API Web HTML5

Bonjour,
Je galère depuis pas mal de jours pour un formulaire php/Booststrap.
C'est un script JQuery qui pose problème.
Il s'agit d'afficher/masquer un menu déroulant (choix d'une langue), puis un autre (choix d'un auteur en fonction du 1er choix) et éventuellement des zones de texte pour préciser les choix.
Tout va bien si on choisit une option qui ouvre un textarea.
Sinon, le choix ne s'affiche pas. Par exemple si on choisit la langue "Grec", le menu déroulant des auteurs s'affiche mais quand on en choisit un, la zone disparaît.
Tout est basé sur des hide/show.
Je vous soumets mon script en précisant que je ne maîtrise pas JQuery. Il peut certainement être simplifié.
Merci par avance si vous pouviez m'orienter vers mon erreur.
Evelyne31


<script language= "javascript">//
    $(document).ready(function() {
    $("#auteur_grec").hide();
    $("#auteur_latin").hide();
    $("#hebreu_biblique").hide();
    $("#text_langue_autre").hide();
    $("#text_hebreu_autre").hide();
    $("#text_grec_inscription").hide();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
    $("#text_latin_inscription").hide();
    $("#text_latin_toponyme").hide();
    $("#text_latin_autre").hide();
    $("#text_hebreu_inscription").hide();
    $("#text_hebreu_toponyme").hide();
    $("#text_hebreu_autre").hide();
    
    $("#langue").change(function() {
    	
    if ( $("#langue").val() == "1"){
    $("#auteur_grec").show();
    $("#auteur_latin").hide();
    $("#hebreu_biblique").hide();
    $("#text_langue_autre").hide();
    $("#text_hebreu_autre").hide();
    $("#text_grec_inscription").hide();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
    $("#text_latin_inscription").hide();
    $("#text_latin_toponyme").hide();
    $("#text_latin_autre").hide();
    $("#text_hebreu_inscription").hide();
    $("#text_hebreu_toponyme").hide();
    $("#text_hebreu_autre").hide();   
    }
    
	    else if ( $("#langue").val() == "2"){
	    $("#auteur_grec").hide();
	    $("#auteur_latin").show();
	    $("#hebreu_biblique").hide();
	    $("#text_langue_autre").hide();
    	$("#text_hebreu_autre").hide();	    
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").hide();
	    $("#text_grec_autre").hide();
	    $("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").hide();
	    $("#text_latin_autre").hide();
		$("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").hide();
   		$("#text_hebreu_autre").hide();    
	    }
	    
	    else if ( $("#langue").val() == "6"){
	    $("#auteur_grec").hide();
	    $("#auteur_latin").hide();
	    $("#hebreu_biblique").show();
	    $("#text_langue_autre").hide();
	    $("#text_hebreu_autre").hide();
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").hide();
	    $("#text_grec_autre").hide();
	   	$("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").hide();
	    $("#text_latin_autre").hide();
	    $("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").hide();
   		$("#text_hebreu_autre").hide();    
	    }
	    
	    else if ( $("#langue").val() == "7"){
	    $("#auteur_grec").hide();
	    $("#auteur_latin").hide();
	    $("#hebreu_biblique").hide();
	    $("#text_langue_autre").show();
	    $("#text_hebreu_autre").hide();
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").hide();
	    $("#text_grec_autre").hide();
	    $("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").hide();
	    $("#text_latin_autre").hide();
	    $("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").hide();
   		$("#text_hebreu_autre").hide();    
	    }  
    
    else {
    $("#auteur_grec").hide();
    $("#auteur_latin").hide();
    $("#hebreu_biblique").hide();
    $("#text_langue_autre").hide();
	$("#text_hebreu_autre").hide();
    $("#text_grec_inscription").hide();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
   	$("#text_latin_inscription").hide();
	$("#text_latin_toponyme").hide();
	$("#text_latin_autre").hide();
	$("#text_hebreu_inscription").hide();
   	$("#text_hebreu_toponyme").hide();
   	$("#text_hebreu_autre").hide(); 
    }
});
        
	$("#auteur_grec").change(function() {
    
    if ( $("#auteur_grec").val() == "20"){
    $("#auteur_grec").show();
    $("#auteur_latin").hide();
    $("#hebreu_biblique").hide();
    $("#text_langue_autre").hide();
	$("#text_hebreu_autre").hide();
    $("#text_grec_inscription").show();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
   	$("#text_latin_inscription").hide();
    $("#text_latin_toponyme").hide();
    $("#text_latin_autre").hide();
    $("#text_hebreu_inscription").hide();
   	$("#text_hebreu_toponyme").hide();
   	$("#text_hebreu_autre").hide();    
    }
    
	    else if ( $("#auteur_grec").val() == "21"){
	    $("#auteur_grec").show();
	    $("#auteur_latin").hide();
	    $("#hebreu_biblique").hide();
	    $("#text_langue_autre").hide();
		$("#text_hebreu_autre").hide();
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").show();
	    $("#text_grec_autre").hide();	    	    
	   	$("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").hide();
	    $("#text_latin_autre").hide();
	    $("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").hide();
   		$("#text_hebreu_autre").hide();    
	    }
	    
	    else if ( $("#auteur_grec").val() == "22"){
	    $("#auteur_grec").show();
	    $("#auteur_latin").hide();
	    $("#hebreu_biblique").hide();
	    $("#text_langue_autre").hide();
		$("#text_hebreu_autre").hide();
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").hide();
	    $("#text_grec_autre").show();
	    $("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").hide();
	    $("#text_latin_autre").hide();
	    $("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").hide();
   		$("#text_hebreu_autre").hide();    
	    }
    
    else {
    $("#auteur_grec").hide();
    $("#auteur_latin").hide();
    $("#hebreu_biblique").hide();
    $("#text_langue_autre").hide();
	$("#text_hebreu_autre").hide();
    $("#text_grec_inscription").hide();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
   	$("#text_latin_inscription").hide();
    $("#text_latin_toponyme").hide();
    $("#text_latin_autre").hide();
    $("#text_hebreu_inscription").hide();
   	$("#text_hebreu_toponyme").hide();
   	$("#text_hebreu_autre").hide(); 
    }
});
    
    $("#auteur_latin").change(function() {
    
    if ( $("#auteur_latin").val() == "19"){
    $("#auteur_grec").hide();
    $("#auteur_latin").show();
    $("#hebreu_biblique").hide();
    $("#text_langue_autre").hide();
	$("#text_hebreu_autre").hide();
    $("#text_grec_inscription").hide();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
   	$("#text_latin_inscription").show();
    $("#text_latin_toponyme").hide();
    $("#text_latin_autre").hide();
    $("#text_hebreu_inscription").hide();
   	$("#text_hebreu_toponyme").hide();
   	$("#text_hebreu_autre").hide();    
    }
    
	    else if ( $("#auteur_latin").val() == "20"){
	    $("#auteur_grec").hide();
	    $("#auteur_latin").show();
	    $("#hebreu_biblique").hide();
	    $("#text_langue_autre").hide();
		$("#text_hebreu_autre").hide();
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").hide();
	    $("#text_grec_autre").hide();	    	    
	   	$("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").show();
	    $("#text_latin_autre").hide();
	    $("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").hide();
   		$("#text_hebreu_autre").hide();    
	    }
	    
	    else if ( $("#auteur_latin").val() == "21"){
	    $("#auteur_grec").hide();
	    $("#auteur_latin").show();
	    $("#hebreu_biblique").hide();
	    $("#text_langue_autre").hide();
		$("#text_hebreu_autre").hide();
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").hide();
	    $("#text_grec_autre").hide();
	    $("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").hide();
	    $("#text_latin_autre").show();
	    $("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").hide();
   		$("#text_hebreu_autre").hide();    
	    }
    
    else {
    $("#auteur_grec").hide();
    $("#auteur_latin").hide();
    $("#hebreu_biblique").hide();
    $("#text_langue_autre").hide();
	$("#text_hebreu_autre").hide();
    $("#text_grec_inscription").hide();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
   	$("#text_latin_inscription").hide();
    $("#text_latin_toponyme").hide();
    $("#text_latin_autre").hide();
    $("#text_hebreu_inscription").hide();
   	$("#text_hebreu_toponyme").hide();
   	$("#text_hebreu_autre").hide(); 
    }     
});

	$("#hebreu_biblique").change(function() {
    
    if ( $("#hebreu_biblique").val() == "4"){
    $("#auteur_grec").hide();
    $("#auteur_latin").hide();
    $("#hebreu_biblique").show();
    $("#text_langue_autre").hide();
	$("#text_hebreu_autre").hide();
    $("#text_grec_inscription").hide();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
   	$("#text_latin_inscription").hide();
    $("#text_latin_toponyme").hide();
    $("#text_latin_autre").hide();
    $("#text_hebreu_inscription").show();
   	$("#text_hebreu_toponyme").hide();
   	$("#text_hebreu_autre").hide();    
    }
    
	    else if ( $("#hebreu_biblique").val() == "5"){
	    $("#auteur_grec").hide();
	    $("#auteur_latin").hide();
	    $("#hebreu_biblique").show();
	    $("#text_langue_autre").hide();
		$("#text_hebreu_autre").hide();
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").hide();
	    $("#text_grec_autre").hide();	    	    
	   	$("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").hide();
	    $("#text_latin_autre").hide();
	    $("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").show();
   		$("#text_hebreu_autre").hide();    
	    }
	    
	    else if ( $("#hebreu_biblique").val() == "6"){
	    $("#auteur_grec").hide();
	    $("#auteur_latin").hide();
	    $("#hebreu_biblique").show();
	    $("#text_langue_autre").hide();
		$("#text_hebreu_autre").hide();
	    $("#text_grec_inscription").hide();
	    $("#text_grec_toponyme").hide();
	    $("#text_grec_autre").hide();
	    $("#text_latin_inscription").hide();
	    $("#text_latin_toponyme").hide();
	    $("#text_latin_autre").hide();
	    $("#text_hebreu_inscription").hide();
   		$("#text_hebreu_toponyme").hide();
   		$("#text_hebreu_autre").show();    
	    }
    
    else {
    $("#auteur_grec").hide();
    $("#auteur_latin").hide();
    $("#hebreu_biblique").hide();
    $("#text_langue_autre").hide();
	$("#text_hebreu_autre").hide();
    $("#text_grec_inscription").hide();
    $("#text_grec_toponyme").hide();
    $("#text_grec_autre").hide();
   	$("#text_latin_inscription").hide();
    $("#text_latin_toponyme").hide();
    $("#text_latin_autre").hide();
    $("#text_hebreu_inscription").hide();
   	$("#text_hebreu_toponyme").hide();
   	$("#text_hebreu_autre").hide(); 
    }
    
    });    
    });     
</script>