Création du fichier js

This commit is contained in:
Yannick Francois 2018-09-28 22:59:58 +02:00
parent 1cc8e6beb4
commit cb07e90e63
2 changed files with 20 additions and 18 deletions

View File

@ -40,24 +40,7 @@
<a href="reponses.html" class="btn" id="next">Continuer</a>
</nav>
<script>
window.onload = () => {
var monStockage = localStorage;
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'))
})
}
</script>
<script src="script.js"></script>
</body>
</html>

19
public/script.js Normal file
View File

@ -0,0 +1,19 @@
window.onload = () => {
var monStockage = localStorage;
if(localStorage.getItem('type_sondage') == undefined) {
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'))
})
}