I’m trying to create an integer update form field for my cart system. On the page, I already have a + and – function to increase and decrease the quantity by 1. How could I include an integer form field next to the (+) and (-) to udpate by a certain result and then send this to the cart page. Thank you very much for any help.
This is the main part of the code that is enclosed within PHP (I left out the information before the first a href link because it isn’t important)
<a href="cart.php?increase=<?php echo $num; ?>"> (+) </a>
<a href="cart.php?remove=<?php echo $num; ?>"> (-) </a>
You’ll have to post a form to
cart.php:And in your cart.php, you can use
if (isset($_POST['submit_increase']))to determine if you’re increasing or decreasing, then$_POST['qty']to grab the number of items to add/remove.This isn’t the only solution. You could use one form, hidden inputs, or javascript to build a query string. Its up to you.