0

I'm trying to pass the ac_no contained in my database table to a form that's displayed within a Bootstrap Modal upon clicking a button. My code is as follows.

<?php
            $mydata = mysql_query("SELECT * FROM slabpay WHERE ac_no='$ac_no'");
                        while($record = mysql_fetch_array($mydata)) 
             { 
             $id=$record['id'];
                  ?>                    
                            <tr class='fired' id='<?php echo $record['id']; ?>'>
                                <td class="center"><?php echo $record['install_no'] ?></td>
                                <td class="center"><?php echo $record['install_amt'] ?></td>
                                <td class="center"><?php echo $record['install_date'] ?></td>
                                <td class="center"><?php echo $record['agent_name'] ?></td>
                                <td id="fired" class="center">
                                                                    <?php
                                                                    if($record['install_amt']=='000000')
                                                                    {
                                                                        ?>

<button class="btn btn-info" data-toggle="modal" data-target="#payAmt" data-id="<?php echo $row['ac_no']; ?>">
  <i class="halflings-icon white edit"></i>    
</button>                                                                        
                                                                    <?php
                                                                    }
                                                                    ?>
                                </td>
                            </tr>

                                                            <?php
            }
?> 

// Javascript Code

<script>
$(document).ready(function(){
       $("#fired").click(function(){
         $("#ac_no").val($(this).attr('data-id')); 
         $('#payAmt').modal('show');
       });
    }); 
</script>


// modal window code

<div id="payAmt" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">            
        <div class="modal-header">

                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

        </div>
        <div class="modal-body">

                        <input type="hidden" class="form-control" id="ac_no" name="ac_no" value="" />
                        <?php
                        $result = $_POST['ac_no'];
                        echo $result;
                        ?>
        </div>
        <div class="modal-footer">
            <a href="#" class="btn" data-dismiss="modal">Close</a>
            <a href="#" class="btn btn-primary">Save changes</a>
        </div>
    </div>

Hope you guys will figure out this problem. Thanks in advance

2
Contributors
2
Replies
15
Views
2 Years
Discussion Span
Last Post by blueguy777
0

Your ajax routine will work off the "save changes" button-link click won't it in the modal footer?

$('.model-footer a.btn-primary').click(function(){
    //run your ajax code here
});
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.