Detect adding to cart
HTML
<form id="say-form" onsubmit="return false;" action="#">
Product A: <input type="text" id="said" value="1" size="5" autocomplete="off" />
<input type="submit" value="Add" />
</form><br />
<br />
<div id="cart"></div>
JavaScript
// Declare VARIABLES and set them same time
var form = document.getElementById( 'say-form' );
var input = document.getElementById( 'said' );
var cart = document.getElementById( 'cart' );
// "form" will now run a function when user submits form
form.onsubmit = function() {
// set the HTML inside the element "cart"
cart.innerHTML = "You have added " + input.value;
};