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>
</nav>
<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>
<script src="script.js"></script>
</body>
</html>

View File

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

View File

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

View File

@ -20,14 +20,14 @@
<section>
<p>
Je m'appelle
<input name="nom" />
<input name="nom" data-group="record" />
et le titre de ce sondage
<select id="type_sondage">
<select id="type_sondage" data-group="record">
<option>classique</option>
<option>special dates</option>
</select>
est
<input name="titre" />.
<input name="titre" data-group="record"/>.
</p>
<p>
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="dates.html" class="btn">Modifier</a>
</nav>
<script src="script.js"></script>
</body>
</html>

View File

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

View File

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

View File

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