显示产品详细信息单击按钮返回false时

时间:2015-03-11 16:53:20

标签: javascript php mysql

当我想显示一个div弹出窗口,当用户点击返回false的按钮时,我就会出现问题。这意味着我无法找到在div弹出窗口中显示产品详细信息而无需再次加载页面的方法。

我正在寻找这样的解决方案以及任何相关的方法。 这是我的代码:

解释:

  • $ product_list用于显示产品,$ product_list2用于显示div Popup。

  • 按钮使用Onclick Add_to_cart()将返回false并从display:none更改div_top1以显示: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.'&nbsp;</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";}
    

0 个答案:

没有答案