Sweet alert working for only in first button

223 views Asked by At

I am using php with Sweet alert I must fetch all appointment and at any appointment user can click on button and confirm reservation by sweet alert the problem is only the first button work with sweet alert !

this my php code:

while ($row=mysqli_fetch_assoc($resultt) ) {
    echo'<p>Tutor name : '.$row['name'].'  <br>This  </p>';
    echo'<ul class="examples">';
    echo'<li class="warning confirm">';
    echo'<div class="ui">';
    echo'<button onClick="reply_click('.$rows['id'].','.$row['id'].','.$tagId.')" >Reserve</button>';
    echo $rows['id'];

    echo'</div>';
    echo'</li>';
    echo'</ul>';
}

If there is multi-button only the first button work!

function reply_click(clicked_id, tutor_id, tag_id) {
    document.querySelector('ul.examples li.warning.confirm button').onclick = function () {
        setTimeout(function () {
            swal({
                    title: "Confirm Reservation",
                    text: "Are You want to confirm reservation ?",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: '#54dd5e',
                    confirmButtonText: 'Yes',
                    closeOnConfirm: false
                },
                function (isConfirm) {
                    if (isConfirm) {
                        window.location.href = "index.php?app=" + clicked_id + "&tutor=" + tutor_id + "&tag=" + tag_id;
                        return $timeout(function () {
                            self.homePageChannel.trigger('deleteForm', self.currentSelectedForm)
                        }, 100);
                    }
                });
        }, 100);
    };
}
0

There are 0 answers