我正在使用带有Sweet警报的php 我必须取得所有预约,在任何预约时,用户都可以点击按钮并通过甜蜜警报确认预约 问题是只有第一个按钮与甜蜜警报一起工作!
这是我的PHP代码: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>';
}
如果有多按钮只有第一个按钮工作!
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);
};
}