[Chartjs]-Chart disappears, when pressing the submit button

1👍

You’re very close, all you need to do is add an event.preventDefault() to prevent the page from actually submitting the form. All you really want to do is call the display() function.

Fiddle here: https://jsfiddle.net/kd4Lnwtj/5/

0👍

From https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button

The default type attribute for any <button> within a <form> is “submit”.

Try adding type="button" to the display button. That should stop it from submitting and just let your JavaScript run.

Something like:

<button type="button" onclick="display(a,b,c,d)">display</button>

Leave a comment