hailinguist

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: newhtml doesn’t work #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>
    in reply to: newhtml doesn’t work #10452
    hailinguist
    Participant

    Hi Jeremy,

    Thanks for your reply.

    I don’t have any other elements labeled “final”. A link to the exp is here if it helps: https://farm.pcibex.net/r/PzVNVH/

Viewing 2 posts - 1 through 2 (of 2 total)