lundi 10 octobre 2016

create dynamic checkbox at modal jquery with data from controller

i have some trouble with this, I create table with button "Bayar", i want make checkbox by the amount of the array, which i get that data from "$result".I use "Username" for the checkbox.

And i get this problems.

i don't know why that checkbox is always appeared double when i click the "Bayar" button. Please.

$('#myModal2').on('show.bs.modal', function(e) {            
      var $modal = $(this),
        esseyidiuran = e.relatedTarget.dataset.idiuran;
        $modal.find('.modal-body #content-id').html(esseyidiuran);

      var locations = [
       <?php
        foreach ($result['data'] as $row) { 
         $username = $row['username'];       

          echo "[ '" . $username . "'], \n";                     
         }
         ?>  
      ];

      var i;
        for (i = 0; i < locations.length; i++) {
          var nama = locations[i][0];
          $('<input type="radio" name="radiobtn" >'+nama+'</input></br>').appendTo('.modal-body');
        }         
    })

This is the screenshot of the problems enter image description here

And if i click on another "Bayar" button, the checkbox was doubled enter image description here




Aucun commentaire:

Enregistrer un commentaire