i'm new php , ran issue adapting else's program. trying implement shopping cart style php , javascript program. shopping cart accepts new entries posting values way of submit button including id, quantity, name , 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 way of commands through php file
if($_get['jcartremove'] && !$_post) { $this->remove_item($_get['jcartremove']); } this command can triggered through
<a href="index.php?jcartremove=apples">no more apples</a> but trigger once. want have list of items
- apples
- oranges
- bananas
and when 1 selected , added cart through form post method, other 2 automatically removed cart. there way use ajax push jcartremove function , remove 2 items id?
any appreciated on this.
rather making multiple ajax calls, you'd better off modifying php , allowing remove function accept array instead of 1 item. pass 1 or many items remove @ once.
for example:
if($_get['jcartremove'] && !$_post) { if (is_array($_get['jcartremove'])) { foreach($_get['jcartremove'] $item) { $this->remove_item($item); } } else { $this->remove_item($_get['jcartremove']); } } your link multiple items:
<a href="index.php?jcartremove[]=apples&jcartremove[]=bananas">no more apples or bananas</a> because we're checking if jscartremove array, can still pass single item have , continue work well.
Comments
Post a Comment