function cart_add_item(type, id, amount_field) { if ((xml_request.readyState == 4) || (xml_request.readyState == 0)) { // get the amount of cards selected if(document.getElementById(amount_field)) { var amount_field = document.getElementById(amount_field); var amount = amount_field.value; } else { var amount = 1; } var post_variables = "t=" + encodeURIComponent(type) + "&id=" + encodeURIComponent(id) + "&a=" + encodeURIComponent(amount); xml_request.open("POST", "shopping_cart_add_item.php", true); xml_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xml_request.onreadystatechange = card_add_item_response; xml_request.send(post_variables); } } function card_add_item_response() { // find the summary cart if(xml_request.readyState == 4) { var summary_cart = document.getElementById('shopping_cart_summary'); summary_cart.innerHTML = xml_request.responseText; } }