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> </select>
</p> </p>
<ul id="responses"> <ul id="responses">
<li>
<a href="responses.html" id="add-response-choice" class="btn next">Ajouter</a>
</li>
</ul> </ul>
</section> </section>
<nav> <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="recapitulatif.html" class="btn next">Continuer</a>
<a href="responses.html" class="btn next">Tout effacer</a> <a href="responses.html" class="btn next">Tout effacer</a>
</nav> </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) => { $$('input').forEach((inputElement) => {
inputElement.addEventListener("change", () => { inputElement.addEventListener("change", () => {
localStorage[inputElement.name] = inputElement.value localStorage[inputElement.name] = inputElement.value
@ -62,13 +72,13 @@ if($("#add-response-choice")) {
$("#add-response-choice").addEventListener('click', (e) => { $("#add-response-choice").addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault();
let response = document.createElement("li"); let response = document.createElement("li");
let text = document.createTextNode("Blabla"); response.appendChild(buildTextField());
response.appendChild(text);
$("#responses").appendChild(response); $("#responses").appendChild(response);
}); });
} }
$$(".next").forEach((button) => { $$(".next").forEach((button) => {
button.addEventListener("click", (e) => { button.addEventListener("click", (e) => {
$$(".toggle-field").forEach((field) => { $$(".toggle-field").forEach((field) => {