0 votes
in SoSci Survey (dt.) by s226998 (170 points)
edited by SoSci Survey

Hallo,

ich habe eine Randomisierung eingestellt bei der es drei Gruppen gibt und 2 der Gruppen einen Text angezeigt bekommen. Die dritte Gruppe bekommt keinen Text angezeigt. Ich möchte jetzt einen Timer einstellen, damit mind 25 Sek die Seite angezeigt wird, allerdings nur für die zwei Gruppen mit Text da die dritte Gruppe ja nicht 25 sek den nicht vorhandenen Text anschauen sollen. Wie kann ich das einstellen? Ich habe diese Code für die Randomisierung:

if (value('RD21') == 2) {
  text('NE03');
} elseif (value('RD21') == 3) {
  text('PO03');
} elseif (value('RD21') == 1) {
  text('KG01');
}

Und

show('RD21');

Für den Timer diesen:

<script type="text/javascript">
<!--
 
var countdown = 25;
var countdownDisplay;
var countdownTimer;
// "submit0" ist der Weiter-Knopf,
// mit "buttonsAuto" kann man auch den Zurück-Knopf ausblenden
var buttonID = "submit0";  
 
function countdownStart() {
  // Next button
  var button = document.getElementById(buttonID);
  // Create countdown element
  countdownDisplay = document.createElement("div");
  var cd = countdownDisplay;
  cd.style.display = "inline-block";
  cd.style.textAlign = "center";
  cd.style.fontWeight = "bold";
  cd.style.width = button.offsetWidth + "px";
  cd.style.height = button.offsetHeight + "px";
  // Init countdown
  button.parentNode.appendChild(countdownDisplay);
  countdownRefresh();
  // Hide next button
  button.style.display = "none";
  // Start countdown
  countdownTimer = window.setInterval(countDown, 1000);
}
 
function countDown() {
  if (countdown > 1) {
    countdown--;
    countdownRefresh();
  } else {
    window.clearTimeout(countdownTimer);
    // Display nextbutton
    var button = document.getElementById(buttonID);
    button.style.display = "";
    // Remove countdown
    button.parentNode.removeChild(countdownDisplay);
  }
}
 
function countdownRefresh() {
  // Clear
  while (countdownDisplay.lastChild) {
    countdownDisplay.removeChild(countdownDisplay.lastChild);
  }
  // Display
  var content = document.createTextNode(countdown + " Sek.");
  countdownDisplay.appendChild(content );
}
 
SoSciTools.attachEvent(window, "load", countdownStart);
 
// -->
</script>

Vielen Dank für die Antwort.

1 Answer

0 votes
by SoSci Survey (306k points)

Speichern Sie den Code für den Timer bitte in einen Text im Fragenkatalog (Darstellung: HTML-Code) und binden Sie den Text mittels text() nur in den Gruppe ein, welche einen Text sehen, z.B.

if (value('RD21') == 2) {
    text('NE03');
    text('JS01');  // Text mit dem JavaScript-Code
} elseif (value('RD21') == 3) {
     text('PO03');
     text('JS01');  // Text mit dem JavaScript-Code
} elseif (value('RD21') == 1) {
     text('KG01');
}

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...