Bifurcation sur le sondate en fonction du choix

This commit is contained in:
Yannick Francois 2018-10-08 22:47:50 +02:00
parent b3b9797e8c
commit 0f6abfa7b9
8 changed files with 28 additions and 38 deletions

View File

@ -33,17 +33,7 @@
<a href="recapitulatif.html" class="btn">Continuer</a> <a href="recapitulatif.html" class="btn">Continuer</a>
</nav> </nav>
<script> <script src="script.js"></script>
window.onload = () => {
console.log("truc");
var monStockage = localStorage;
console.log("key ? storage : ", localStorage.type_sondage);
document.querySelector('#type_sondage').addEventListener('change', function() {
localStorage.setItem('type_sondage', this.options[this.selectedIndex].text);
})
}
</script>
</body> </body>
</html> </html>

View File

@ -36,5 +36,6 @@
</form> </form>
</section> </section>
<script src="script.js"></script>
</body> </body>
</html> </html>

View File

@ -73,6 +73,8 @@
<a href="validations.html" class="btn">Continuer</a> <a href="validations.html" class="btn">Continuer</a>
<a href="dates.html" class="btn">Modifier</a> <a href="dates.html" class="btn">Modifier</a>
</nav> </nav>
<script src="script.js"></script>
</body> </body>
</html> </html>

View File

@ -20,14 +20,14 @@
<section> <section>
<p> <p>
Je m'appelle Je m'appelle
<input name="nom" /> <input name="nom" data-group="record" />
et le titre de ce sondage et le titre de ce sondage
<select id="type_sondage"> <select id="type_sondage" data-group="record">
<option>classique</option> <option>classique</option>
<option>special dates</option> <option>special dates</option>
</select> </select>
est est
<input name="titre" />. <input name="titre" data-group="record"/>.
</p> </p>
<p> <p>
Si je devais le décrire pour les autres personnes, je dirais Si je devais le décrire pour les autres personnes, je dirais

View File

@ -52,6 +52,8 @@
<a href="notifications.html" class="btn">Continuer</a> <a href="notifications.html" class="btn">Continuer</a>
<a href="dates.html" class="btn">Modifier</a> <a href="dates.html" class="btn">Modifier</a>
</nav> </nav>
<script src="script.js"></script>
</body> </body>
</html> </html>

View File

@ -39,11 +39,7 @@
<a href="recapitulatif.html" class="btn next">Continuer</a> <a href="recapitulatif.html" class="btn next">Continuer</a>
</nav> </nav>
<script> <script src="script.js"></script>
window.onload = () => {
var monStockage = localStorage;
}
</script>
</body> </body>
</html> </html>

View File

@ -1,19 +1,21 @@
window.onload = () => { window.onload = () => {
var monStockage = localStorage; if(localStorage.getItem('type_sondage') == null) {
if(localStorage.getItem('type_sondage') == undefined) {
localStorage.setItem('type_sondage', 'classique'); localStorage.setItem('type_sondage', 'classique');
} }
document.querySelector('#type_sondage').addEventListener('change', function() { console.debug(localStorage)
let typeSondageElement = document.querySelectorAll("*[data-group='record']")
typeSondageElement.forEach((currentElement) => {
currentElement.addEventListener('change', function() {
const selectedType = this.options[this.selectedIndex].text; const selectedType = this.options[this.selectedIndex].text;
localStorage.setItem('type_sondage', type_sondage); localStorage.setItem('type_sondage', type_sondage);
console.log(selectedType);
if(selectedType == "classique") { if(selectedType == "classique") {
document.querySelector('#next').href = "reponses.html"; document.querySelector('#next').href = "reponses.html";
} else { } else {
document.querySelector('#next').href = "dates.html"; document.querySelector('#next').href = "dates.html";
} }
console.log(document.querySelector('#next'))
}) })
});
} }

View File

@ -21,10 +21,7 @@
<h1>C'est tout bon !</h1> <h1>C'est tout bon !</h1>
</section> </section>
<script src="script.js"></script>
</body> </body>
</html> </html>