Search code examples
javascriptonclickreload

Onclick reload with other onclick function


Is there someone who know if its posible to use 2 onclick in 1 button? I hope to get reload page when i push the button.

Here is the orginal button:

<a href="javascript:;" onclick="javascript:articleToCart('<z:esc mode="js" value=$z:value[article.number]>', document.getElementById('amount$z:iteration[article.current]').value)">

Best Regards Frank

EDIT:

My version works, but i cant find the way to get the return false to work. This works in IE and Firefox.

<center><input type="button" class="flowbutton" value="Kjøp" onclick="document.location.reload(true);javascript:articleToCart('<z:esc mode="js" value=$z:value[article.number]>',document.getElementById('amount$z:iteration[art‌​icle.current]').value)"> </center>


Solution

  • If you call a function, which you already do, you can do as much in the javascript as you want.

    <script type="text/javascript">
        function articleToCartMain() {
            articleToCart('<z:esc mode="js" value=$z:value[article.number]>', document.getElementById('amount$z:iteration[article.current]').value);
            //Put other function calls in here as well
            return false; //Prevents the page from reloading or scrolling to top
        }
    </script>
    <a href="#" onclick="return articleToCartMain();">Do something</a>