function onQuantityChange(id) { var quantity=$( "#"+id+" option:selected" ).text(); $.ajax({ type: "POST", dataType: "json", url: "cart.php?id="+id+"&quantity="+quantity, success: function(data) { $('.success, .warning, .attention, .information, .error').remove(); if(data.HTML!=null) { //code to update the view on page } else { alert("Unable to get it"); } }, error: function(){ alert("Error in event:onselect"); } }); }
for($i=0;$i<count($_SESSION["contents"]);$i++) { $sql="select * from products where ID=".$_SESSION["contents"][$i]["ItemCode"]; $con->Query($sql); while($row=$con->Row()) { echo "<tr>"; echo "<td class=\"name\">"; echo "<a href=\"\">".$row->Name." ".$row->Unit."</a>"; echo "</td>"; echo "<td class=\"details\"><span class=\"MRP\">Rs $row->MRP</span></td><td class=\"details\"><span class=\"details\">Rs $row->SP</span>"; echo "</td>"; echo "</td>"; echo "<td class=\"quantity\">"; echo "<select id=\"$row->ID\" onchange=\"onQuantityChange('$row->ID')\" >"; for($j=1;$j<21;$j++) { if($j==$_SESSION["contents"][$i]["quantity"]) { echo "<option value=\"$j\" selected>$j</option>"; } else { echo "<option value=$j>$j</option>"; } } echo "</select>"; echo "</td>"; echo "<td id=\"$row->ID\" class=\"total\">".$_SESSION["contents"][$i]["quantity"]*$row->SP."</td>"; echo "<td class=\"remove\">"; echo "<img src=\"Stylesheets/image/remove.png\" >ID')\" title=\"Remove\"/>"; echo "</td>"; echo "</tr>"; } } } else { echo "contents array doesnt exists."; } echo "</tbody>"; echo "</table>"; echo "</div>"; echo "<div class=\"cart-totals\">"; echo "<table class=\"right\">"; echo "<tr>"; echo "<td class=\"total\" width=\"200px\" align=\"right\">"; echo "<h3>Shipping</h3>"; echo "</td>"; echo "<td class=\"total\" width=\"70px\" align=\"right\">"; echo "Free"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"total\" width=\"200px\" align=\"right\">"; echo "<h3>Total</h3>"; echo "</td>"; echo "<td class=\"total\" width=\"70px\" align=\"right\">"; echo "<h3 id=\"FinalTotal\">Rs ".$_SESSION["total"]."</h3>"; echo "</td>"; echo "<td class=\"total\" width=\"40px\">"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; echo "</div>"; echo "<div id=\"BackForthButtons\">"; echo "<div class=\"checkout\">"; echo "<div class=\"cart-modules left\">"; echo "</div></div><div class=\"right\"><a class=\"button\" href=\"checkout.php\">"; echo "<span class=\"proceed\">Checkout</span></a></div>"; echo "<div class=\"right\">"; echo "<a class=\"button\" href=\"http://www.cartup.in\" style=\"background: #454545; margin: 2px 5px;\">"; echo "<span class=\"continue\">Add more items</span>"; echo "</a>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)