I've a PHP file hyper-linked and I'm calling a javascript function on click of link to check some condition and display alert box.
I simply want button to stop any action (Should not call PHP file) after I click the OK button in alert box if the condition two is true
My HTML code is
<a onclick="combocheck()" id="btnlabel" title="Buy Now" class="btn icon-Add To Cart" href="http://www.fxpure.in/cart.php?action=add&product_id=86">Select Design</a>
After clicking the link, it add the item to the cart and opens a lightbox with details.
I have added a function
function combocheck()
{
var noitems = document.getElementById("cartitems").innerHTML;
if (noitems == "") {
alert ("Your Cart is Empty, Please Proceed.");
} else if (noitems != "") {
alert ("Your cart already have some items, you can not purchase other items along with the combo");
}
}
What I want is, if the condition 2 is true, the item should not be added to the cart and no lightbox should be displayed.