Prevent Javascript to submit to server

hi there, 

i copy a menu of javascript to an expression in a webblock:

where the javascript is like this:

var coll = document.getElementsByClassName("collapsible");
var i;

for (i = 0; i < coll.length; i++) {
    coll[i].addEventListener("click", function() {
        var content = this.nextElementSibling;
        if ( === "block") {
   = "none";
        } else {
   = "block";


The trouble is that when i click the button menu, the collapsable works. Unfortunately, it submit to server. The question is How to make javascript not to submit to server?

thank you, best regards.

Hello Pasar,

Not sure why you're using a JavaScript menu when OutSystems provides 2 level menu functionality out of the box (3 level is too much already).

In any case, your JavaScript does not submit to server (in a fast reading).

I would say the it is bound to an element that is inside a link.



Hi Edu,

Thank you for quick reply.

We use our company's theme and wanna template like Dublin's. Then i copy that code, unfortunately when put in the Outsystems,it is submitted (different from the wwwschool). I guess this is the default of Outsystems's and then i put in the top of the javascript:

SyntaxEditor Code Snippet


after changing the Javascript signature to:

 coll[i].addEventListener("click", function(event) {

and fortunately, it works.. although i do not know the reason behind that.