0

I have a problem while passing selected value to bootstrap modal for editing selected record. i searched a lot but couldn't find proper way to solve my problem. Can anyone help me this regard.

<a href="#myModalUpdate" data-Id="<?php echo $row[0]; ?>" id="update"  role="button"                                                 class="btn btn small btn primary btn-validate" data-toggle="modal" >Update</a>
Model
<div class="modal fade" id="myModalUpdate"  tabindex="-1" role="dialog" aria-   labelledby="myModalLabel" aria-hidden="true" style= margin-top: 40px;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
 <h4 class="modal-title" id="myModalLabel">Update Trainee</h4>
</div>
<div class="modal-body" id="updateBody" >
 <?php          
  $traineeID = $_POST['id'];
  echo $traineeID;?>
</div>  
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
</div>
</div>
</div>
</div>
<script>
     $(document).ready(function(){
       $('a.Update').click(function(){
          var id = $(this).data('id');
            $('#myModalUpdate').val(id);
              });
            });
            </script>
Th4t Guy
  • 1,434
  • 2
  • 16
  • 28
  • you can set the html manually.. $('#modal .modal-header h3').html('Are you sure you want to delete article #2?'); $('#modal .modal-body').html('some test body'); .. the bootstrap modal doesn't handle random values you pass – Ananth Aug 25 '14 at 04:16
  • This question is off topic. You should show your code. – Manwal Aug 25 '14 at 04:16
  • Or if you want to load an edit form inside the modal, you need to have an ajax request, and load the ajax form response into the modal-body – Ananth Aug 25 '14 at 04:17
  • I have post my code too is there anyone to help me in this regard – user3382076 Aug 25 '14 at 05:30
  • possible duplicate of [Passing data to a bootstrap modal](http://stackoverflow.com/questions/10626885/passing-data-to-a-bootstrap-modal) – Dan Aug 25 '14 at 15:06

0 Answers0