2015-08-11 2 views

ответ

0
<html> 
    <head> 
     <meta charset="utf-8"> 
     <meta http-equiv="X-UA-Compatible" content="chrome=1"> 
     <link rel="stylesheet" type="text/css" href="bootstrap.min.css"> 
    </head> 
    <body> 
     this is a simple way only 
     i make use of bootstrap and jquery 
     <br/> 
     this are buttons generated by the php 
     <br/> 
     you can create a element data attribute where in you can put 
     <br/> 
     your php contents to be transfer to the modal or popup 
     <br/> 
     <button type="button" class="btn btn-primary clickbutton" data-toggle="modal" data-target=".bs-example-modal-sm" data-transfer="This is a data that i am holding generated by the php">Small modal</button> 

     <button type="button" class="btn btn-primary clickbutton" data-toggle="modal" data-target=".bs-example-modal-sm" data-transfer="This is a data that i am holding generated by the php sample 2">Small modal1</button> 

     <div id="popup" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"> 
      <div class="modal-dialog modal-sm"> 
      <div class="modal-content"> 
       <p>Sample Test Data</p> 
      </div> 
      </div> 
     </div> 

     <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js"></script> 
     <script src="bootstrap.min.js"></script> 
     <script type="text/javascript"> 
      $(document).ready(function() { 
       // bind on click event on the button once it was open 
       // change the contents of modal or the popup 
       // contents 
       $('.clickbutton').on('click', function() { 
        // get the data-transfer attribute and 
        // send it to modal/popup data 
        var data = $(this).attr('data-transfer'); 
        // change the content of the modal using javascript 
        // jquery dom manipulation 
        $('#popup').find('.modal-content p').html(data); 
       }); 

      }); 

      </script> 
    </body> 
</html> 
Смежные вопросы