@addison
To pass data to a modal in CodeIgniter, you can simply pass the data as an argument when loading the modal view. Here is an example of how to pass data to a modal in CodeIgniter:
In your controller:
1 2 3 4 5 6 |
public function show_modal() { $data['modal_data'] = 'This is some data to be passed to the modal'; $this->load->view('modal_view', $data); } |
In your modal view (modal_view.php):
1 2 3 4 5 6 |
<div id="myModal" class="modal"> <div class="modal-content"> <span class="close">×</span> <p><?php echo $modal_data; ?></p> </div> </div> |
In your main view, where you want to show the modal:
1 2 3 4 5 6 7 8 9 10 11 |
<button onclick="showModal()">Open Modal</button> <script> function showModal() { // Get the modal var modal = document.getElementById("myModal"); // Show the modal modal.style.display = "block"; } </script> |
In this example, the data 'This is some data to be passed to the modal' is passed to the modal view when loading it in the controller. This data is then displayed in the modal view using PHP. When the user clicks on the button, the modal is shown and the data is displayed in the modal content.