Pass parameter to modal window

Asked

Viewed 681 times

1

I have a link that calls a modal bootstrap and I need that when it is clicked, the modal window is opened and a data is loaded in it that was sent as parameter by the link.

The modal link and call is as follows:

<a class="navbar-brand" href="#" data-toggle="modal" data-target="#basicModal"><i class="fa fa-times"></i></a>

And that’s the modal window code:

    <div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true" data-backdrop="static">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">Modal</h4>
                                        </div>
                                        <div class="modal-body">
                                            <input type="text" id="demo"  value="">                                               
                                            <h3> Conteúdo</h3>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
                                            <button type="button" class="btn btn-primary">Salvar</button>
                                        </div>
                                    </div>
                                </div>
                            </div>

Does anyone know how I can do this?

  • Do you want to load the contents of an "external" url dynamically into a modal? Where is this parameter at the current url?

  • Take a look at this link, it talks about using the . modal-content: http://stackoverflow.com/questions/18378720/bootstrap-3-with-remote-modal?answertab=votes#tab-top

  • Not specifically. Actually, as I’m new to WEB programming, I don’t even know which way to go. For example, if it were on different pages, you could for example send something via url, and on another page recover the value that was sent using Php’s GET method. As the modal window is on the same page of the link that calls it, I don’t know what to do.

  • If you just want to display information that is already on the page (url in your case), just add the content inside the <div class="modal-body"> Seu Conteúdo </div>. Just remember to use the following means to retrieve the information: <?php&#xA; $my_string = filter_input(INPUT_GET, ‘my_string’, FILTER_SANITIZE_STRING);&#xA;?> Source: (http://www.phparch.com/2010/07/never-use-_get-Again/) I hope this is it and I didn’t get it wrong...

  • Unfortunately it didn’t work out.

  • this modal div, is on the same page of the link that opens it ?

  • Yes, the modal is on the same page. I was able to solve with the example of this link : http://jsfiddle.net/k7FC2/ .

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.