Knowledge Management

Get Involved. Join the Conversation.

Topic

    Liz Tarren
    JavaScript in Knowledge Base Answer
    Topic posted May 10, 2019 by Liz TarrenGreen Ribbon: 100+ Points, last edited May 10, 2019, tagged Knowledge Advanced, Knowledge Foundation 
    59 Views
    Title:
    JavaScript in Knowledge Base Answer
    Summary:
    The javascript doesn't seem to work
    Content:

    Dear all,

    I have a javascript embedded in the html source code on a KB Answer (cf. below source code). When I press the html button linked to the function "clear_all()" then test1 is  correctly shown, but not test2, even though I do have a div with an ID called contentDiv. I am wondering if I have done something wrong, even though the code works outside KnowledgeBase...

     

    <div style="background-color: rgb(0,0,0); color: white">
    <form action="#" class="form_class" id="form_id" method="post" name="form_name">
    <input id="btn_id" name="submit_id" onclick="clear_all()" type="button" value="Check the courses" />

    </form>
    </div>

    <div id="contentDiv">This is the content.</div>

    <script type="text/javascript" >
    function clear_all() {
    alert("test1");
    var eleDiv= document.getElementByID("contentDiv");
    alert("test2");

    }

    </script>

    Kind regards,

    Liz