将商品ID从卡片传递到模态

问题描述 投票:0回答:1

所以我有3张卡,其值取自数据库我想获取被单击的特定卡的ID并将其发送给模态,以便我可以在模态中回显它。

我尝试将其作为data-id = 发送到按钮触发器,但这似乎不起作用

php & mysql codes to fetch from database  

<div class="container">
<div class="title">
    <h5><?php echo $card_id; ?></h5> <h1><?php echo $card_title; ?></h1>
    <div class="body">
        <?php echo $card_name; ?>
        <button type="button" data-toggle="modal" data-target="#myModal" name="button" data></button>
    </div>
</div>

<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">
    <!-- Modal content-->
<div class="modal-content">
  <div class="modal-header">
    <h4 class="modal-title">Modal Header</h4>
  </div>
  <div class="modal-body">
    <h1><?php echo $card_id; ?></h1>
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  </div>
</div>

所以我有3张卡,其值取自数据库,我想获取被单击的特定卡的ID并将其发送给模态,以便我可以在模态中回显它,我尝试将其发送给...

javascript php jquery mysql bootstrap-modal
1个回答
0
投票

您可以考虑为此使用Ajax。

© www.soinside.com 2019 - 2024. All rights reserved.