PennController for IBEX › Forums › Support › newhtml doesn’t work › Reply To: newhtml doesn’t work
April 15, 2023 at 6:30 pm
#10453
hailinguist
Participant
Hi Jeremy,
I changed my code to the following, and the final page shows up:
newTrial("completion", newHtml("completion", "completion.html") .print() .wait() )
However, the function I created in the HTML file for generating a code does not work (i.e., the code simply doesn’t show up). The same HTML file works as intended in the old Ibex: [“completion”, “Form”, {continueMessage: null, html: { include: “completion.html” } } ].
Below is the content of the HTML file. May I know what caused the problem? Thank you so much!
<!DOCTYPE html> <html> <body> <p>恭喜您已经完成了该实验。感谢您的参与。</p> <p>为了获取报酬,请您复制下面的11位数编码,然后点击下面链接或者扫码打开腾讯问卷,在问卷里填写该编码。</p> <p>每个编码只能使用一次。请不要和别人分享。</p> <h3 id="demo"></h3> <p>腾讯问卷链接</p> <img src="qrcode.png" width="300" /> <script> function functionName() { let alphanum = "0123456789"; let code2 = ""; let randChar; while (true) { for (i = 0; i < 10; i++) { randChar = alphanum.charAt(Math.floor(Math.random()*alphanum.length)); code2 += randChar; } if (code2.length > 10) { code2 = ""; } if (code2 % 11 === 1) { break; } } return code2; } document.getElementById("demo").innerHTML = functionName(); </script> </body> </html>