dto52236 2016-05-29 08:40
浏览 13

从php发送bootstrap模式中的值

<a id="modal-107547" href="#modal-container-107547" class="btn btn-default btn-flat" data-toggle="modal">Profile</a>

This button links to a bootstrap modal as below.

<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
             <a id="modal-107547" href="#modal-container-107547" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

            <div class="modal fade" id="modal-container-107547" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">

                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                ×
                            </button>
                            <h4 class="modal-title" id="myModalLabel">
                                Modal title
                            </h4>
                        </div>
                        <div class="modal-body">
                            ...
                        </div>
                        <div class="modal-footer">

                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                Close
                            </button> 
                            <button type="button" class="btn btn-primary">
                                Save changes
                            </button>
                        </div>
                    </div>

                </div>

            </div>

        </div>
    </div>
</div>

Is there any method to send a value to the model when I clicked the profile button like we used something.php?id="value" in get method.

  • 写回答

2条回答 默认 最新

  • dongyuelian9602 2016-05-29 09:01
    关注

    The button does not submit a form, nor link to another page. The modal is opened with JavaScript on clicking the button. So, there is no opportunity for PHP to get involved in the communication between the two (unless you were to use AJAX, which it seems would be an unnecessarily long way of doing what you're trying to accomplish).

    You would have to pass values, between the button and the modal, with JavaScript/jQuery.

    The acutual values to be sent, though, can be inserted in PHP (on generating the HTML for the button and the modal). Something like this:

    echo '<a id="modal-107547" href="#modal-container-107547" class="btn btn-default btn-flat" data-toggle="modal" data-some-variable='. $variable .'>Profile</a>'
    

    You would then use JS/JQuery to do something when the button is clicked.

    EDIT: if you need a hand with the JS/jQuery, see this question and answers:

    Passing data to a bootstrap modal

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP