abonne-toiture
Coder
hey guy
I'm working a MCQ and would like to have random number to be display for my question and my answers.
basicaly, I have 12 names assign to 12 numbers and I have to choose in 5 answers which one is the correct one.
First question is working because, it is the fisrt time it is called but all the next questions are not working.
My questions is like this:
Answers:
My script:
I'm 100% beginner with java so be nice ;-) I'm running the all thing with learndash on a wordpress site.
I hope you will be able to help me, Many Thanks Last question, my script is only working when it is after my MCQ not before, could you please explain why ?
I'm working a MCQ and would like to have random number to be display for my question and my answers.
basicaly, I have 12 names assign to 12 numbers and I have to choose in 5 answers which one is the correct one.
First question is working because, it is the fisrt time it is called but all the next questions are not working.
My questions is like this:
HTML:
<div class="wp-block-columns has-3-columns">
<div class="wp-block-column">
<p id="left">aucun...<div id="question1"></div></p>
<p id="left">purge...<div id="question2"></div></p>
<p id="left">fripé...<div id="question3"></div></p>
<p id="left">saxes...<div id="question4"></div></p>
</div>
<div class="wp-block-column">
<p id="left">torde...<div id="question5"></div></p>
<p id="left">mufle...<div id="question6"></div></p>
<p id="left">oraux...<div id="question7"></div></p>
<p id="left">dégel...<div id="question8"></div></p>
</div>
<div class="wp-block-column">
<p id="left">dépôt...<div id="question9"></div></p>
<p id="left">herbe...<div id="question10"></div></p>
<p id="left">anaux...<div id="question11"></div></p>
<p id="left">eûtes...<div id="question12"></div></p>
</div>
</div>
<h3 class="aligncenter">aucun ?</h3>
HTML:
<p id="rep1"></p><p id="rep4"></p><p id="rep6"></p><p id="rep2"></p><p id="rep12"></p>
My script:
JavaScript:
<script>
let name1 = document.getElementById("question1").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg1 = document.getElementById('rep1');
msg1.innerHTML = name1;
</script>
<script>
let name2 = document.getElementById("question2").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg2 = document.getElementById('rep2');
msg2.innerHTML = name2;
</script>
<script>
let name3 = document.getElementById("question3").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg3 = document.getElementById('rep3');
msg3.innerHTML = name3;
</script>
<script>
let name4 = document.getElementById("question4").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg4 = document.getElementById('rep4');
msg4.innerHTML = name4;
</script>
<script>
let name5 = document.getElementById("question5").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg5 = document.getElementById('rep5');
msg5.innerHTML = name5;
</script>
<script>
let name6 = document.getElementById("question6").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg6 = document.getElementById('rep6');
msg6.innerHTML = name6;
</script>
<script>
let name7 = document.getElementById("question7").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg7 = document.getElementById('rep7');
msg7.innerHTML = name7;
</script><script>
let name8 = document.getElementById("question8").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg8 = document.getElementById('rep8');
msg8.innerHTML = name8;
</script>
<script>
let name9 = document.getElementById("question9").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg9 = document.getElementById('rep9');
msg9.innerHTML = name9;
</script>
<script>
let name10 = document.getElementById("question10").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg10 = document.getElementById('rep10');
msg10.innerHTML = name10;
</script>
<script>
let name11 = document.getElementById("question11").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg11 = document.getElementById('rep11');
msg11.innerHTML = name11;
</script>
<script>
let name12 = document.getElementById("question12").innerHTML = Math.floor(Math.random() * 10000)+1000;
let msg12 = document.getElementById('rep12');
msg12.innerHTML = name12;
</script>
I'm 100% beginner with java so be nice ;-) I'm running the all thing with learndash on a wordpress site.
I hope you will be able to help me, Many Thanks Last question, my script is only working when it is after my MCQ not before, could you please explain why ?