Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As webgal suggested, AJAX is the way forward. Have the plus/minus buttons calling a function, say <code>updateQuantity(direction)</code> where direction is up or down (depending on the button clicked. So, the plus button will call <code>updateQuantity(1)</code> and the minus button will call <code>updateQuantity(-1)</code> and use that value to manipulate the object's quantity in the cart.</p> <p>Simple AJAX code (which you'll simply need to tailor to your own need) will be as follows:</p> <pre><code>function updateQuantity(direction){ var xmlhttp; if(window.XMLHttpRequest){ // For new browsers and IE7+ xmlhttp=new XMLHttpRequest(); console.log('created XMLHttpRequest'); }else{ // For old IE versions (volatile) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); console.log('created ActiveXObject'); } xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200){ //if the AJAX call is finished and the HTTP status is 200 (OK) console.log('response received'); var e = document.getElementById('theElementYouWantToChange'); e.innerHTML = xmlhttp.responseText; }else if(xmlhttp.readyState==4 &amp;&amp; xmlhttp.status!=200){ //second if condition specified, else the console will log an error //whenever the readystate changes, and this happens 3 times during //an acceptable AJAX call console.log("Error retrieving search response. Status: "+xmlhttp.status); } } xmlhttp.open("GET","includes/updateCart.php?product="+productID+"&amp;change="+direction,true); xmlhttp.send(); } </code></pre> <p>You will need to set up the variable productID which attaches to the product you are modifying the quantity of</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload