1

如果 $row_thumbs['Listino 9'] 中包含的价格不为空,我想用“添加到购物车”按钮显示这个 div。那怎么能做到呢?jQuery?

<div id="button" style="padding: 10px 0px 10px 0px;">    
      <form name="eCart1_1_ATC_<?php echo $row_thumbs["Cod."]; ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
      <input type="hidden" name="eCart1_1_ID_Add" value="<?php echo $row_thumbs["Cod."]; ?>" >
      <input type="hidden" name="eCart1_1_Quantity_Add" value="1" size="2" >
      <input type="image" src="images/acquista.png" width="95"  border="0" class="eC_ImageButton" value="Aggiungi al carrello" name="eCart1_1_ATC"></form>     
      </div>
4

1 回答 1

1

取消注释第一行,然后将显示 BUTTON,确保脚本在服务器上运行,而且我永远不会创建空格 $row_thumbs['ListinoHERE9']

<?php

    //$row_thumbs['Listino_9']='cheater';

    if($row_thumbs['Listino_9']!='') {
        echo '<div class="button"> B U T T O N</div>';
    }
?>
<style type="text/css">
.button {
    padding:5px;
    width:100px;
    background-color:gray;
}
.button:hover {
    cursor:pointer;
    background-color:orange;

}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">

$(document).ready(function(){
    $('.button').click(function(){
        $('.show-div-if-button-gets-clicked').toggle();
    });
});
</script>

<div class="show-div-if-button-gets-clicked" style="display:none;">
    <form name="eCart1_1_ATC_<?php echo $row_thumbs["Cod."]; ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
    <input type="hidden" name="eCart1_1_ID_Add" value="<?php echo $row_thumbs["Cod."]; ?>" >
    <input type="hidden" name="eCart1_1_Quantity_Add" value="1" size="2" >
    <input type="image" src="images/acquista.png" width="95"  border="0" class="eC_ImageButton" value="Aggiungi al carrello" name="eCart1_1_ATC"></form>     
</div>
于 2013-03-13T21:30:29.927 回答