Stop script from executing if conditions match
<p>When user clicks a submit button, the script modifies a shopping cart printed on the page. However, if the user clicks it again, it will add the same line's again, and I need to stop it. </p>

<p><strong>So I only want the script to modify the contents of the page only once, and do nothing if the contents have already changed.</strong></p>

<p>Here's what I've tried:</p>

<pre><code>$(document).ready(function () {
    $(function () {
        $(".submit").click(function () {
            var a = $('.simpleCart_input').val();
            var a1 = $('.simpleCart_input').val();
            if (a1 == a + " kpl") {
                return false;
            } else {
                $('.itemRow .item-quantity').text(a + " kpl");
            }
            var b = $('.itemRow .item-price').html();
            var b1 = $('.itemRow .item-price').html();
            if (b1 == b + " /kpl") {
                return false;
            } else {
                $('.itemRow .item-price').text(b + " /kpl");
            }
            var c = $('.itemRow .item-total').html();
            var c1 = $('.itemRow .item-total').html();
            if (c1 == "Yhteensä: " + c) {
                return false;
            } else {
                $('.itemRow .item-total').text("Yhteensä: " + c);
            }
            var d = $('.simpleCart_grandTotal').html();
            var d1 = $('.simpleCart_grandTotal').html();
            if (d1 == "Tuotteet yhteensä " + d) {
                return false;
            } else {
                $('.simpleCart_grandTotal').text("Tuotteet yhteensä " + d);
            }
            var data = $('#yhteystiedot').serializeArray();
            data.push({
                name: 'cartContent',
                value: $('#emailedcart').html()
            });
            //alert (data);return false;
            $.ajax({
                type: "POST",
                data: data,
                url: "order/order.php",
                dataType: "html",
                error: function () {
                    alert("Jotakin meni pahasti pieleen! Yritä uudelleen?");
                },
                success: function () {
                    alert("Onnistui");
                }


            });
            return false;

        });
    });
});
</code></pre>

<p>This just won't work for me. </p>

<p><a href="http://jsfiddle.net/UUYqx/" rel="nofollow">Sample</a></p>
