Prevent form from refreshing the page
<p>Hey I am trying to use a form to submit data via JavaScript but it keeps refreshing the page when I don't want it to.</p>

<p>My form is like this:</p>

<pre><code>&lt;form name="myForm" method="post"&gt;

&lt;input type="text" name="name"/&gt;
&lt;input type="submit" name="add" value="Add Resource" onclick="insert(); return false;"/&gt;

&lt;/form&gt;
</code></pre>

<p>My JS function has:</p>

<pre><code>function insert(e){
e.preventDefault();
    var name = document.myForm.name;
    console.log(name);    
}
</code></pre>

<p>I was told prevent default is how you stop the default action of the form but it still happens for me. How do I fix it ?</p>
