function in javascript not working when called
<p>I have a javascript code that works by removing the first and the last line of it. </p>

<p>Please take a look at <a href="http://jsfiddle.net/subTZ/59/" rel="nofollow">JSFiddle</a> </p>

<p>for people who wants to see it in here, here is my html:</p>

<pre><code>&lt;input id="search" onclick="search()" type="button" value="Search"/&gt;
</code></pre>

<p>my javascript : </p>

<pre><code>    function search() {
var search = document.getElementById('search');

var int = setInterval(function() {
    if (search.value.length == 6)
        search.value = 'Searchi';
    else if (search.value.length == 7)
        search.value = 'Searchin';
    else if (search.value.length == 8)
    search.value = 'Searching';
    else {
        search.value= 'Search';
            }
    //clearInterval( int ); // at some point, clear the setInterval
}, 500);

}
</code></pre>

<p>I want the function to work only when I click the button.</p>
