lundi 28 novembre 2016

Getting the value of id from html pass to php code snippet

I really hope someone can help as I'm having a tough time trying to pass the count from html attribute to php code snippets as coded below. Or is it possible to manipulate/convert to php since i need the id to get the count to be use the value inside php block.

@foreach($trans as $tran)
<tr>
 <td>{!! $tran->sponsor_id !!}</td>
 <td>{!! $tran->ship_id !!}</td>
 <th>                               
     <a class="btn" href="#" data-image-id="" data-toggle="modal" data-title="{!! $tran->tran_message !!}" 
        data-count="{!! count($tran['listImage']) !!}"
        data-target="#image-gallery"><button>View Info</button></a>
    </th>
</tr>                         
@endforeach

<script type="text/javascript">
    $(document).ready(function(){
        loadGallery(true, 'a.btn');
        function loadGallery(setIDs, setClickAttr){
            var current_image,
            selector,
            images,
            counter = 0;
            function updateGallery(selector) {
                var $sel = selector;
                images = $sel.data('count');

                current_image = $sel.data('image-id');


                $('#image-gallery-count').text($sel.data('count'));
                $('#image-gallery-caption').text($sel.data('caption'));
                $('#image-gallery-title').text($sel.data('title'));

                var b = (64 + parseInt(images.toString()));
                var a = 65;
                for (i = a; i <= b; i++) {   
                   var letter = String.fromCharCode(i);
                   $('#image-gallery-image-'+String.fromCharCode(i)).attr('src', $sel.data('image-'+String.fromCharCode(i)));
               };


               disableButtons(counter, $sel.data('image-id'));
           }

           if(setIDs == true){
            $('[data-image-id]').each(function(){
                counter++;
                $(this).attr('data-image-id',counter);
            });
        }
        $(setClickAttr).on('click',function(){
            updateGallery($(this));
        });
    }
});
</script>

//Here is the count i need to get inside php code snippet

 <h4 id="image-gallery-count"></h4>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire