JQuery Onclick display selected info
Posted
by
Emily
on Stack Overflow
See other posts from Stack Overflow
or by Emily
Published on 2013-06-25T09:37:38Z
Indexed on
2013/06/25
10:21 UTC
Read the original article
Hit count: 203
I want to display the selected price
, category
and size
on the dropdown slideingDiv
. But what I have done below is not working. I have try to echo out to see if the data have been sent thought but I got nothing. Is anything wrong with my code?
Script
<script type="text/javascript">
$(document).ready(function () {
$(".slidingDiv").hide();
$(".show_hide").show();
$('.show_hide').click(function () {
$(".slidingDiv").slideToggle();
});
});
</script>
Button
<button a href="product.php?ProdID=<?php echo $id; ?>" class="show_hide" id="button" name="button">Add to cart</a></button>
PHP
<div class="slidingDiv">
<?php
dbconnect();
$pid = $_POST['pid'];
$length = $_POST["size"];
$qty = $_POST['Qty'];
$Category = $_POST['Category'];
$stmt4 = $conn->prepare("
SELECT Product.Name as ProductName, Category.Name, size, Price
FROM item_Product, Product, Category
WHERE Product.ProdID =:pid
AND size= :length AND Category.Name = :Category Limit 1");
$stmt4->bindParam('pid',$pid);
$stmt4->bindParam('length',$length);
$stmt4->bindParam('Category',$Category);
$stmt4->execute();
foreach ($stmt4->fetchAll(PDO::FETCH_ASSOC) as $row4 ) {
$product_name = $row4["ProductName"];
$price = $row4["Price"];
$length = $row4["size"];
$Category = $row4["Name"];
?>
Item was added shopping bag </br>
Name:<?php echo $row4['ProductName']; ?> </br>
Length:<?php echo $row4['size']; ?> </br>
Category:<?php echo $row4['Name']; ?> </br>
Price:<?php echo $row4['Price']; ?> </br>
<?php }
?>
<a href="cart.php">View Cart</a>
</div>
© Stack Overflow or respective owner