I have a foreach loop that outputs a form with content for each array entry as per bellow.
$cartOutput .= '<td><form action="cart.php" method="post">
<input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" id="quantity" />
<input name="adjustBtn' . $item_id . '" type="submit" value="change" id="adjustBtn" hidden="true" />
<input name="item_to_adjust" type="hidden" value="' . $item_id . '" />
</form></td>';
As you can see the submit button has a unique assigned name for depending on the item.
In my jquery file i have the bellow.
$('#quantity').change(function(){
$("[name^=adjustBtn]").closest("form").submit();
});
This works on the first form on the page but any additional form does not auto submit on change, i believe the name^=adjustBtn entry is grabbing all of the different buttons but im just not sure how to tell it which one to submit etc.
You seem to need
Your id doesn’t seem needed. And beware that you can’t have more than one element with a given id (problem with “quantity” and “adjustBtn” in your code).