I'm fairly new to php and ran into an issue adapting someone else's program. I am trying to implement a shopping cart style php and javascript program. The shopping cart accepts new entries by POSTing values by way of a submit button including id, quantity, name and price.
<form method="post" style="border:0px solid yellow;" ><fieldset>
<input type="hidden" name="jcartToken" value="<?php echo $_SESSION['jcartToken'];?>" />
<input type="hidden" name="my-item-id" value="1" />
<input type="hidden" name="my-item-name" value="apples" />
<input type="hidden" name="my-item-price" value="2" />
<input type="hidden" name="my-item-qty" value="1" size="3" />
<input id="apples" type="submit" name="my-add-button" class="add" value=" "/>Apples - $2
</fieldset></form>
The cart removes items by way of GET commands through the php file
if($_GET['jcartRemove'] && !$_POST) {
$this->remove_item($_GET['jcartRemove']);
}
This GET command can be triggered through
<a href="index.php?jcartRemove=apples">no more apples</a>
But this will only trigger once. What I want is to have a list of items
- apples
- oranges
- bananas
and when one is selected and added to the cart through the form post method, the other two are automatically removed from the cart. Is there a way to use AJAX to push the jcartRemove function and remove two items by their ID?
Any help would be appreciated on this.