每当单击按钮时,我想填充每个数组值:
while($row=mysql_fetch_array($qry)){
$prodId = $row["ProductID"];
$imgID = $row["ImageID"];
$prodName = $row["ProductName"];
$prodPrice = $row["ProductPrice"];
$prodDesc = $row["prodDesc"];
$imgURL = $row["ImageUrl"];
$proNum = $prodId;
$dynamicListCol1 = '<div class="thumbnail" style="margin-bottom:10px;">
<img src="' . $imgURL . '" width="200" height="300" class="img-responsive" alt="Responsive image">
<center>
<div class="caption">
<h4>' . $prodName . '</h4>
<p>Price: $' . $prodPrice . ' <br>Description: ' . $prodDesc . ' <br></p>
<a data-toggle="modal" href="#cartModal">
<button type="submit" class="btn btn-success" id="btnCart">
<i class="icon-shopping-cart"></i> Cart it</button>
</a>
<a data-toggle="modal" href="#prodModal"><button type="submit" class="btn btn-info">
<i class="icon-search"></i> View it</button>
</a>
</div>
</center>
</div>';
echo $dynamicListCol1;
我想在单击btnCart
时获取$prodName
和$prodPrice
的每个值。并将其填充在模态的表中。
Product Price
Ebook $200
Ebook2 $150
等等等等...
您必须编写JS代码,每次单击按钮时都会发送AJAX请求。在此 AJAX 请求中,您将填充数据并发送回浏览器准备的 HTML,就像您在问题中生成的那样。收到响应后,您的 JS 代码必须显示 TB 模式弹出窗口,并在 AJAX 响应中收到 HTML。