// ADHESION AFPS // REMPLIR LE FORMULAIRE POUR LES ÉLÈVES ///////////////////////////////////////// ///////////////////////////////////////// // ÉLÈVE // 5 MAX ///////////////////////////////////////// ///////////////////////////////////////// ///////////////////////////////////////// // VARIABLE var eleve = "0"; var instrumentAB; let contenuhtml_eleve; ///////////////////////////////////////// // AU CHARGEMENT DE LA PAGE UNIQUEMENT POUR LES FAMILLES, PAS POUR LES PROFS // ON AFFICHE LE PREMIER ELEVE if (window.location.pathname === "/adhesion/adhesion_famille") { window.onload = ajout_eleve(0); }; // quand le visiteur clique sur "ajouter un élève" function ajout_eleve(eleve) { afficheeleve(eleve); } function ajout_prof_eleve(checkboxElem,eleve) { // si box diplome checked on affiche if (checkboxElem.checked) { // On vérifie que la prof ou le statgiaire s'inscrit également if (check_prof_diplome.checked || check_prof_formation.checked) { afficheeleve(eleve); } else { alert("Vous devez ajouter un diplôme ou une formation pour le professeur avant d'ajouter son enfant"); } } else { // si box diplome unchecked on supprime supprimer_eleve_all(); } } ///////////////////////////////////////// // SAISIE DES INFORMATIONS POUR UN ÉLÈVE ///////////////////////////////////////// function afficheeleve(eleve) { eleve++; // Le nombre d'élève est atteint if (eleve > 5 ) { console.log("5 élèves maximum atteint"); return; } // on rempli la variable "contenuhtml_eleve" du contenu html à afficher // Ce if sert pour ne pas répéter plusieurs fois le même numéro de eleve si l'internaute clique plusieurs fois sur le même "ajouter une eleve" if (!document.querySelector('#eleve'+ eleve +'')) { contenuhtml_eleve = `

icone informationÉLÈVE `+ eleve +``; // Permettre de supprimer les élèves ajoutés if (eleve > 1) { contenuhtml_eleve += ` `; }; contenuhtml_eleve += `

`; if (eleve < 5) { contenuhtml_eleve += ""+ ``+ ``+ `
`+ ``+ ``+ `
` }; contenuhtml_eleve += `
`; eleve--; // AFFICHER LE FORMULAIRE DE SAISIE D'UN ELEVE APRÈS LE DERNIER document.querySelector('#eleve'+ eleve +'').insertAdjacentHTML("afterend",contenuhtml_eleve); eleve++; return eleve; } } function select_prof(eleve,instrumentAB) { console.log("instrumentAB = " + instrumentAB); console.log("ID content = " + document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"")); let instrument_saisie = document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"").value; console.log("instrument_saisie = ", instrument_saisie); if (instrument_saisie == "Alto"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Contrebasse"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Flûte traversière"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Guitare"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Harpe"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Orgue"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Piano"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Trompette"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Violon"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "Violoncelle"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (instrument_saisie == "SECE"){ contenuhtml_prof = ` `; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; if (!instrument_saisie){ contenuhtml_prof = ``; document.getElementById("eleve_"+ eleve +"_instrument"+ instrumentAB +"_prof").innerHTML = contenuhtml_prof; contenuhtml_prof =''; }; } function supprimer_eleve(eleve) { document.querySelector('#eleve'+ eleve +'').remove(); } function supprimer_eleve_all() { if (document.querySelector('#eleve1')) {document.querySelector('#eleve1').remove()}; if (document.querySelector('#eleve2')) {document.querySelector('#eleve2').remove()}; if (document.querySelector('#eleve3')) {document.querySelector('#eleve3').remove()}; if (document.querySelector('#eleve4')) {document.querySelector('#eleve4').remove()}; if (document.querySelector('#eleve5')) {document.querySelector('#eleve5').remove()}; if (document.querySelector('#eleve6')) {document.querySelector('#eleve6').remove()}; }