My page updates fine when I use the pulldown menus BUT The problem is that when the Qty is at higher numbers for some reason I have to click the REMOVE button several times. The amount of times I click the Remove button does not match the Qty … It seems to always be a random amount of times I have to click the Remove button for the Item to be removed…
One time I had to click the Remove Button 11 times before it removed the item? It is very strange. And Some time I only have to click it once.
Can anyone please look at my code below and see if you find anything that would cause this problem…
This code is at the top of my CART.PHP page:
[code]if (isset($_GET[‘action’])) {
if ($_GET[‘action’] == “RemoveItem”) {
$Remove_Item = 1;
$UpdateQty_okay = 0;
$qty_okay = 0;
if (isset($_GET['Removeid'])) {
$Remove_id = 1;
$RemoveSCID = $_GET['Removeid'];
} else {
$Remove_id = 0;
$RemoveSCID = $_GET['Removeid'];
}
} elseif ($_GET['action'] == "UpdateQty") {
$UpdateQty_okay = 1;
$Remove_Item = 0;
$Remove_id = 0;
if (isset($_GET['id'])) {
$SC_ID = $_GET['id'];
$id_okay = 1;
} else {
$id_okay = 0;
}
if (isset($_GET['qty'])) {
$NewQty = $_GET['qty'];
$qty_okay = 1;
} else {
$qty_okay = 0;
}
} else {
// Do nothing ... The Action was not Remove or Update...
}
// Remove Item from Shopping Cart Database
if (($Remove_Item == 1) && ($Remove_id == 1)) {
$query_delete = "DELETE FROM tblshoppingcart WHERE ShoppingCart_ID = {$RemoveSCID}";
mysql_select_db($database_DM_database, $DM_database);
$Results = mysql_query($query_delete, $DM_database) or die(mysql_error());
//header("Location: cart.php");
// Update QTY into Shopping Cart Database
} elseif (($UpdateQty_okay == 1) && ($id_okay == 1) && ($qty_okay == 1)) {
$query = "UPDATE tblshoppingcart SET qty = {$NewQty} WHERE ShoppingCart_ID = {$SC_ID}";
mysql_select_db($database_DM_database, $DM_database);
$Result = mysql_query($query, $DM_database) or die("query='$Result '<br>".mysql_error());
header("Location: cart.php");
} else {
// Do Nothing ... The One of the Varibles were ZERO...
}
} else {
// Do Nothing … The Varible $_GET[‘action’] was NOT SET.
}[/code]
This is the Code for the JavaScript that sends the page:
[code][/code]
This is the code of the Pulldown menu that uses the the UpdateQty from the Javascript:
<select name="<?php echo $row_rsSCProduct["ShoppingCart_ID"]; ?>" onChange="UpdateQty(this)">
<?php
for($i = 1; $i <= 20; $i++) {
echo "<option ";
if($row_rsSCProduct["qty"] == $i) {
echo " SELECTED ";
$RealQTY = $i;
}
echo ">" . $i . "</option>";
}
?>
</select>
This is the code for the Remove button that uses the Remove Javascript code:
<input name="<?php echo $row_rsSCProduct["ShoppingCart_ID"]; ?>" type="image" src="../images/product_remove_cart.jpg" alt="Remove Item" onClick="RemoveItem(this)"/>