28 lines
No EOL
1.2 KiB
Text
28 lines
No EOL
1.2 KiB
Text
<h2> <%= question[:vraag] %> </h2>
|
|
<select id="<%= question[:vraag] %>">
|
|
<option value="" selected="selected disabled hidden">Maak uw keuze</option>
|
|
<% for answer in question[:antwoorden]%>
|
|
<option value="<%= answer[:tekst] %>">
|
|
<%= answer[:tekst] %>
|
|
</option>
|
|
<% end %>
|
|
</select>
|
|
<% for answer in question[:antwoorden]%>
|
|
<% if answer[:vraag] %>
|
|
<%# Should store all sub-questions with a reference to their parent question in the data-parent
|
|
attribute, however, these atrtibutes remain empty. %>
|
|
<div id=<%= answer[:vraag]%> style="display:none;" data-parent="<% question[:vraag] %>">
|
|
<%= render '/partials/question.*', question: answer %>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<script>
|
|
document.getElementById("<%= question[:vraag] %>").addEventListener('change', (event) =>{
|
|
// find subquestions of this question and set display:initial;
|
|
console.log("<%= question[:vraag] %>");
|
|
// If the data-parent attributes would be filled, this would find the relevant sub-questions
|
|
// they could then be made visible again.
|
|
console.log(document.querySelectorAll('[data-parent="<%= question[:vraag] %>"]'));
|
|
})
|
|
</script> |