How come this doesn't stop the form from submitting/ reloading the page?
<p>I am trying to build a little search script, but can't seem to stop the page from re-loading when you hit submit. There is probably something wrong with my code: </p>

<pre><code>function searchThat(e) {
    if (!e) e = window.event;
    e.preventDefault();

    if (searchFor.indexOf(searchIn) != -1) {
        console.log('we found it');
    }
}
</code></pre>

<p>Thanks a bunch!</p>

<p>I am calling it with</p>

<pre><code>    if (searchFor &amp;&amp; searchIn &amp;&amp; searchSubmit) {
    addEvent(searchSubmit, 'submit', searchThat)
    }
</code></pre>

<p>and:</p>

<pre><code>function addEvent(elem, evtType, func) {
    if (elem.addEventListener) {
        elem.addEventListener(evtType, func, false);
    } else if (elem.attachEvent) {
        elem.attachEvent("on" + evtType, func);
    } else {
        elem["on" + evtType] = func;
    }
}
</code></pre>

<p>and the HTML:</p>

<pre><code>&lt;div class="container"&gt;
    &lt;form&gt;
        &lt;p&gt;Search for:&lt;/p&gt;
        &lt;p class="mrm"&gt;
            &lt;input type="text" id="searchFor" name="searchFor"&gt;
        &lt;/p&gt;
        &lt;p&gt;In:&lt;/p&gt;
        &lt;textarea class="mrm" type="text" id="searchIn" name="searchIn"&gt;&lt;/textarea&gt;
        &lt;p&gt;
            &lt;input type="submit" class="clicker nmb" id="searchSubmit" name="searchSubmit"&gt;
        &lt;/p&gt;
    &lt;/form&gt;
&lt;/div&gt;
</code></pre>
