Alewa's avatar
Level 2

Attendance

Lets say you have a database like admins, departments and department_admins. Now you want to create attendance for all admins, but you want to filter the admins by departments on the attendance table, to mark the attendance for present or absent and you will display all the attendance by date, so when you click on the date it will show you all the admins and their attendance on that date. How do you do this in laravel 5.6 with javascript. Can someone please help me?

0 likes
1 reply
jlrdw's avatar

How do you do this in laravel 5.6 with javascript.

Plain javascript, Vue, jquery, react, angular,..

What code have you tried so far.

You will need ajax to make a call to the database to retrieve the data.

Have you taken any javascript ajax tutorials prior. Ajax just returns data you can work with however you need.

As example bringing up data to edit:

https://drive.google.com/file/d/0B1_PFw--3o74TC16eXRBYXZBNFk/view

A basic jquery response takes this form:

<script>

    $(function () {

        $("#testme").click(function (event)
        {
            event.preventDefault();
            var somevar = '3'; // Usually a variable generated by you
                                  // for demo hard coded
            $.ajax({
                url: 'testg',
                type: 'GET',
                data: 'somevar=' + somevar,
                dataType: 'json',
                success: function (data) {
                    $.each(data, function (index, item) {
                        alert(item.dogname);
                         // loop and do whatever with data
                    });
                },
                error: function (err) {
                    alert(err);
                }
            });

        });


    });

</script>

Please or to participate in this conversation.