Custom HTML Not Rendering Correctly

  • The HTML block previewer shows the code working mostly as intended (for some reason the preview doesn’t let the alert function send an alert) but does not render the same way after publishing. How can I fix this? It is supposed to show a radio button and send an alert with text depending on which radio button is pressed; but neither the alert or the radio button is shown.

    Code in question below:

    <script type="text/javascript">
    function showRight(){alert("Correct");}
    function showWrong(){alert("Incorrect");}
    </script>
    <div>Insert Question here<br>
    <label><input type="radio" name="test" onclick="showRight()">Right Answer</label><br>
    <label><input type="radio" name="test" onclick="showWrong()">Wrong Answer</label><br>
    <label><input type="radio" name="test" onclick="showWrong()">Wrong Answer</label><br>
    <label><input type="radio" name="test" onclick="showWrong()">Wrong Answer</label><br>
    </div>

    Code from external IDE:

    <!DOCTYPE html>
    <html>
    <body>
    
    <script type="text/javascript">
    function showRight(){alert("Correct");}
    function showWrong(){alert("Incorrect");}
    </script>
    <div>Insert Question here<br>
    <label><input type="radio" name="test" onclick="showRight()">Right Answer</label><br>
    <label><input type="radio" name="test" onclick="showWrong()">Wrong Answer</label><br>
    <label><input type="radio" name="test" onclick="showWrong()">Wrong Answer</label><br>
    <label><input type="radio" name="test" onclick="showWrong()">Wrong Answer</label><br>
    </div>
    </body>
    </html> 

    The blog I need help with is: (visible only to logged in users)

  • The code you can use on the wordpress.com platform is very limited. Javascript is one of those codes you can’t use.

  • The topic ‘Custom HTML Not Rendering Correctly’ is closed to new replies.