vielen Dank! Das Problem hatte ich (durch eine Bereinigung des html textes) gelöst.
Jetzt habe ich neue Fragen (und Fragennamen) erstellt - Fragebogen für ein Projekt neu und sauberer angelegt, allerdings bricht der code jetzt schon wieder ab. Die Filterfrage wird noch angezeigt, aber es passiert nichts, wenn ich eine der beiden Alternativen auswähle. Diesmal scheint es (zumindest in meiner laienhaften fehlersuche) aber nicht am html code zu liegen.
Könnten sie mir helfen?
Die Definitionen der Fragen und Textelemente oben (Referenzen ) sind neu, sonst ist alles gleich geblieben
https://www.soscisurvey.de/discefrn_rating_ads/?act=SHyLrdwS406qU44t5n4JDQZr
<script type="text/javascript">
// Get references to options, questions, and text elements
var optionA = document.getElementById("QN01_01a");
var optionB = document.getElementById("QN01_02a");
var frage1 = document.getElementById("QN09_qst");
var frage2 = document.getElementById("QN17_qst");
var textA102a = document.getElementById("Text even a");
var textA102b = document.getElementById("Text even b");
var textA103a = document.getElementById("Text uneven a");
var textA103b = document.getElementById("Text uneven b");
var container = document.getElementById("container");
// Function to toggle the display sequence based on the selected option
function toggle() {
console.log("Toggle function executed"); // Debugging log
container.innerHTML = ""; // Clear container
if (optionA.checked) {
console.log("Option A selected"); // Debugging log
// Add text and questions for Option A with spacing
textA102a.style.marginBottom = "15px"; // Add space below text
frage1.style.marginBottom = "50px"; // Add space below question
textA102b.style.marginBottom = "15px";
container.appendChild(textA102a);
container.appendChild(frage1);
container.appendChild(textA102b);
container.appendChild(frage2);
} else if (optionB.checked) {
console.log("Option B selected"); // Debugging log
// Add text and questions for Option B with spacing
textA103a.style.marginBottom = "15px"; // Add space below text
frage2.style.marginBottom = "50px"; // Add space below question
textA103b.style.marginBottom = "15px";
container.appendChild(textA103a);
container.appendChild(frage2);
container.appendChild(textA103b);
container.appendChild(frage1);
} else {
console.log("No option selected"); // Debugging log
}
}
// Attach the toggle function to the click event of each option
optionA.addEventListener("click", toggle);
optionB.addEventListener("click", toggle);
// Execute the function initially to set the correct display state
window.addEventListener("load", function() {
toggle();
});</script>