I'm comming up with a problem when i want to display a div Pop-up that appears when users click a button returning false. This mean I can't find ways to display a product detail in div pop-up without loading a page again.
I'm looking for a solution like this and any relevant ways. Here is my code:
Explain:
$product_list is used for displaying products and $product_list2 is used for display div Popup.
-
Button With Onclick Add_to_cart() will return false and change div_top1 from display: none to display: block.
<?php include 'Config.php'; $product_list = ""; $product_list2 = array(0 => ""); $sql = mysql_query ('SELECT * FROM sanpham ORDER BY id DESC'); $product_count = mysql_num_rows ($sql); $a=0; if ($product_count >0) { while ($row = mysql_fetch_array ($sql)){ $ID = $row["ID"]; $ID2 = $row["ID2"]; $a++; $product_name = $row["productname"]; $price = $row["Price"]; $product_list .= '<td class="table_cell_sellingsection"><img src="Productimages/'.$ID.'.png" class="imagesproduct" alt=""> <p>'.$product_name.' </p> <hr> <p class="price_product">Price: '.$price.' vnđ</p> <p> <form name="Addtocart" method="post" action="" > <input type="hidden" name="pid" value="'.$ID.'"> <button class="Button-Addtocart" type="submit" onclick="Add_to_Cart()"> <img class="Add_to_cart" src="images/Addtocart.png" width="65" height="26" alt=""> </button> </form> <button id ="button-click" type="submit" class="Button-detail" onclick="changediv()"> <img class="Button-detail-img" src="images/Detail.gif" width="70" height="26" alt=""></p></td>'; array_push($product_list2, '<div id="div_top1"> <div class="div-detail"> <table width="100%" height="100%" border="0" cellspacing="3" cellpadding="4"> <tr> <td class="headname" height="55" colspan="3">'.$product_name.'</td> </tr> <tr> <td width="35%" height="273" rowspan="1"><img class="imagesproduct1" src="Barefoot_2014_DVD_Cover.jpg" width="1024" height="687" alt=""></td> <td class="info-more" width="65%"> PRICE: VNĐ <hr> DESCRIPTION <hr> <span class="des-info">Chất liệu: Cotton<br> Thoáng mát phù hợp với mọi lứa tuổi Đảm bảo chất lượng cao, số lượng có hạn, click để mua!</span> </td> </tr> <tr> <td class="size-product" width="35%" height="57"> <span style="padding-right: 30px;">SIZE</span> X XL XXL </td> <td><form name="Addtocart" method="post" action="" > <input type="hidden" name="pid2" value="'.$ID2.'"> <input type="hidden" name="pid" value="'.$ID.'"> <button class="Button-Addtocart" type="submit" onclick="Add_to_Cart()"> <img class="Add_to_cart" src="images/Addtocart.png" width="65" height="26" alt=""></button> </form> <button id ="button-click" type="submit" class="Button-detail" onclick="changediv()"><img class="Button-detail-img" src="images/Detail.gif" width="70" height="26" alt=""> </td></tr></table></div></div>');} } else {echo "You have no product";}