The value of my id
is always 10 ( the last number in my array).
This works fine for my jQuery function, but when using it with the value attribute: it always gives me 10 when doing the get request.
When inspecting my website :
value is ok!
When doing a var dump : notice the second value.
I really need this to work to get to the other page.
I'm a bit stucked.
foreach ($data as $key => $value)
{
if ($count % 4 == 0 && $count != 0)
{
echo "<div class=\"container\">";
echo "<div class=\"row\">";
echo "</div>";
echo "</div>";
echo "<br> <br>";
}
$id = $value['id'];
echo "<div class=\"col-sm-3\">";
echo "<form method='get' action='..\product\details' class='product-form'>";
$img = $value["img"];
$category = $value["category"];
echo "<div class='panel panel-primary $category' >";
echo "<div class='panel-heading'>".$value["name"]."</div>";
echo "<div class='panel-body'><img src='../../public/img/$img' class='img-responsive' style='width:100%' alt='Image'></div>";
echo " <div class=\"panel-footer\">".$value["description"]."<br><button type='button' class='btn btn-default cart-button' onclick='addToCart($id)'><span class='glyphicon glyphicon-shopping-cart'></span></button></div>";
echo "<input type='hidden' name='itemid' value='$id'>";
echo "</form>";
echo "</div>";
echo "</div>";
$count++;
}
To submit the form I use this:
$(function () {
$(".col-sm-3").click(function test(event) {
$(".product-form").submit();
})
})