SQL While 语句中的 Bootstrap Modal 不断显示第一条记录内容

我是新手。我正在转换一个包含发布表单的工作 Bootstrap 模式。使用带有 Id 的按钮打开模式。它总是在打开时显示在 SQL while 语句结果列表中找到的第一条记录的 FORM 内容。我将模态从 id 更改为一个类。我现在用类按钮而不是 id 按钮打开它。但是现在它一直显示第二条记录的表单内容。如果我从模态中取出表格,它可以正常工作并显示正确的内容。accept-btn 打开模式。('.confirm-body') 包含模态内容表单。请感谢一些帮助。


<!-- Opens modal is outside the modal-->

<a class="accept-btn">Accept</a>

<!-- The Modal -->

<div class="modal">

  <!-- Modal content -->

  <div class="modal-content animate confirmarea-size">

    <div id="topblue-border1" class="topblue-border1"></div> <!-- topblue border End -->

    <!-- Popup buttons Start -->  

    <div class="confirm-body boxshadow" style="display:none;">

      <form class="whatever" action="" method=""> 

        <input type="hidden" class="whatever" name="" value="<?php echo whatever?>"> 

        <input type="hidden" class="whatever" name="" value="<?php echo whatever?>">

        <input type="hidden" class="whatever" name="" value="<?php echo whatever?>">

        <div class="ajax-response"></div>

        <a><div id="css-btn" class="confirm-btn">Accept</div></a>

        <a><div id="css-btn" class="cancel-btn">Cancel</div></a>

        <a><div id="css-btn" class="nextstage-btn">OK</div></a>

      </form>   

    </div> <!-- Popup Confirm Section END --> 

  </div> <!-- End of The Modal Content -->      

</div> <!-- End of The Modal -->



1st Option Button script

<script>

// Accept button Opens the Modal .

$(document).ready(function() {

  $('.accept-btn').click(function(event) {

    $('.modal').show();

    $('.confirm-body').show();

  });

});

</script>


2nd Option button  script.  I want to try something like this but I dont know how to code it and close it correctly. each recored has a record Id field.  I want to relate the modal to the record id.



森栏
浏览 106回答 1
1回答

拉风的咖菲猫

我已经解决了这个问题。一些绕过它的方法很好,比如 AJAX GET Posted here 是有效的。但我知道必须有另一种方法不需要 AJAX GET 命令,而是对模态进行微小的更改,因为我的另一个问题是我在另一个项目上的其他模态包含模态形式的用户输入字段,返回 Js 查询在通过 Ajax 发布表单之前打开 mondal。经过大量的测试和痛苦之后,我找到了解决方案,因为我知道答案在于模态 ID 是静态的。我怎样才能使它动态并匹配 SQL $row id 和 Button ID。答案就在下面。在包含行的 Sql 数据库 $row [recordid] 或 ID 的 php 变量中创建。现在,这是确保您获得正确数据所需的变量。$id &nbsp;= &nbsp; &nbsp; "". $row["id"]."";在您用来打开模式的按钮中回显记录 id 变量。保持!变量前的哈希#: <button type="button" class="accept-btn" data-toggle="modal" data-target="#<?php echo $id;?>"> 模态 Div - 删除#myModal 并回显 id php 变量。不要放哈希#&nbsp;<div id="<?php echo $id;?>" class="modal"> 就这样了。因此,当您单击任何行中的模态按钮时,它将显示正确的内容/形式。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript