Ajout d'un champ texte en cas de sondage classique

avancement sur le #20
This commit is contained in:
Yannick Francois 2018-11-08 15:28:08 +01:00
parent cdbe0a12e1
commit 45319fcfd6
2 changed files with 13 additions and 5 deletions

View File

@ -29,14 +29,12 @@
</select>
</p>
<ul id="responses">
<li>
<a href="responses.html" id="add-response-choice" class="btn next">Ajouter</a>
</li>
</ul>
</section>
<nav>
<a href="responses.html" id="add-response-choice" class="btn next">Ajouter</a>
<a href="recapitulatif.html" class="btn next">Continuer</a>
<a href="responses.html" class="btn next">Tout effacer</a>
</nav>

View File

@ -52,6 +52,16 @@ const createModal = (text) => {
});
}
const buildTextField = () => {
var field = document.createElement("input")
var deleteButton = document.createElement("button")
var fieldBloc = document.createElement("span")
fieldBloc.appendChild(field);
fieldBloc.appendChild(deleteButton);
return fieldBloc
}
$$('input').forEach((inputElement) => {
inputElement.addEventListener("change", () => {
localStorage[inputElement.name] = inputElement.value
@ -62,13 +72,13 @@ if($("#add-response-choice")) {
$("#add-response-choice").addEventListener('click', (e) => {
e.preventDefault();
let response = document.createElement("li");
let text = document.createTextNode("Blabla");
response.appendChild(text);
response.appendChild(buildTextField());
$("#responses").appendChild(response);
});
}
$$(".next").forEach((button) => {
button.addEventListener("click", (e) => {
$$(".toggle-field").forEach((field) => {