我正在使用ajax填充日期(如图1所示)。您单击“选择”以选择所需的日期,然后弹出一个提供时间段的模态弹出窗口(通过复选框,如图2_2所示)。 选中所需时间段的复选框后,将关闭模式,然后填写并提交表单的其余部分。 我在从模式中捕获ID和选定的复选框时遇到了一些困难,因为当我将其发送到数据库时,什么也没有发生。表单信息的其余部分将提交给数据库中其分配的区域(日期和时隙除外)。 因此,我显然缺少从模态捕获ID和复选框信息的信息,以了解更新的位置。
图片1
图片2
我尝试了几种捕获ID和信息的方法,包括将ID放入选择按钮并以这种方式以及“ GET”请求捕获它,但是没有运气。
我将感谢您的见解,并感谢您的投入。
以下是模态代码,因此您可以看到填充的ID和信息。(请注意,这是模态代码的上半部分和下半部分,因为这是很多代码并不会都适合这里)。
<!-- SCHEDULE TIMESLOT MODAL -->
<div class="modal fade" id="selectDate<?php echo $idDate;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><i class="fa fa-calendar"></i> <?php echo $day_of_week ." ". $full_date;?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-danger" role="alert">
<h4 style="font-size:20px !important;" class="alert-heading"><i class="fa fa-exclamation-triangle"></i> Notice</h4>
<p>Select your appointment time from the green check boxes. If your appointment goes over the three hour time window please use the block function for the additional times that are needed.</p>
</div>
<div class="row">
<?php
$query = "SELECT * FROM jobschedule_101 WHERE iddate = '$idDate'";
$select_date = mysqli_query($connection, $query);
confirm($select_date);
while($row = mysqli_fetch_array($select_date)){
// JOB ONE ////////////////////
$timeSlotOneJobOneChk = "
<div class='form-check form-check-inline'>
<input class='form-check-input' type='checkbox' value='1' name='slotOneJobOne' id='slotOneJobOne'>
<label class='form-check-label text-success' for='defaultCheck1'>
6AM-8AM (1)
</label>
</div>
<div class='form-check form-check-inline ml-3'>
<input class='form-check-input' type='checkbox' value='2' name='slotOneJobOne' id='slotOneJobOne'>
<label class='form-check-label' for='inlineCheckbox2'>Block</label>
</div>
";
// TIME SLOT ONE
if($timeSlotOneAvailability == 1){
$timeSlotOneJobTwoChk = "";
$timeSlotOneJobThreeChk = "";
$timeSlotOneJobFourChk = "";
}
if($timeSlotOneAvailability == 2){
$timeSlotOneJobThreeChk = "";
$timeSlotOneJobFourChk = "";
}
if($timeSlotOneAvailability == 3){
$timeSlotOneJobFourChk = "";
}
// TIME SLOT TWO
if($timeSlotTwoAvailability == 1){
$timeSlotTwoJobTwoChk = "";
$timeSlotTwoJobThreeChk = "";
$timeSlotTwoJobFourChk = "";
}
if($timeSlotTwoAvailability == 2){
$timeSlotTwoJobThreeChk = "";
$timeSlotTwoJobFourChk = "";
}
if($timeSlotTwoAvailability == 3){
$timeSlotTwoJobFourChk = "";
}
// TIME SLOT THREE
if($timeSlotThreeAvailability == 1){
$timeSlotThreeJobTwoChk = "";
$timeSlotThreeJobThreeChk = "";
$timeSlotThreeJobFourChk = "";
}
if($timeSlotThreeAvailability == 2){
$timeSlotThreeJobThreeChk = "";
$timeSlotThreeJobFourChk = "";
}
if($timeSlotThreeAvailability == 3){
$timeSlotThreeJobFourChk = "";
}
// TIME SLOT FOUR
if($timeSlotFourAvailability == 1){
$timeSlotFourJobTwoChk = "";
$timeSlotFourJobThreeChk = "";
$timeSlotFourJobFourChk = "";
}
if($timeSlotFourAvailability == 2){
$timeSlotFourJobThreeChk = "";
$timeSlotFourJobFourChk = "";
}
if($timeSlotFourAvailability == 3){
$timeSlotFourJobFourChk = "";
}
// TIME SLOT FIVE
if($timeSlotFiveAvailability == 1){
$timeSlotFiveJobTwoChk = "";
$timeSlotFiveJobThreeChk = "";
$timeSlotFiveJobFourChk = "";
}
if($timeSlotFiveAvailability == 2){
$timeSlotFiveJobThreeChk = "";
$timeSlotFiveJobFourChk = "";
}
if($timeSlotFiveAvailability == 3){
$timeSlotFiveJobFourChk = "";
}
/// END JOB AVAILABILITY VALIDAITON /////
$schedule_block_job_one = "
<div class='col-5 p-2 pb-4 m-1 bg-light shadow-sm'>
<div class='form-check pl-5 pt-2 mb-0 time-slot'>
$timeSlotOneJobOneChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotOneJobTwoChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotOneJobThreeChk
</div>
<div class='form-check pl-5 pb-2 mb-2 time-slot'>
$timeSlotOneJobFourChk
</div>
<div class='form-check pl-5 pt-2 mb-0 time-slot'>
$timeSlotTwoJobOneChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotTwoJobTwoChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotTwoJobThreeChk
</div>
<div class='form-check pl-5 pb-2 mb-2 time-slot'>
$timeSlotTwoJobFourChk
</div>
<div class='form-check pl-5 pt-2 mb-0 time-slot'>
$timeSlotThreeJobOneChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotThreeJobTwoChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotThreeJobThreeChk
</div>
<div class='form-check pl-5 pb-2 mb-2 time-slot'>
$timeSlotThreeJobFourChk
</div>
</div>
<div class='col-5 p-2 pb-4 m-1 bg-light shadow-sm'>
<div class='form-check pl-5 pt-2 mb-0 time-slot'>
$timeSlotFourJobOneChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotFourJobTwoChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotFourJobThreeChk
</div>
<div class='form-check pl-5 pb-2 mb-2 time-slot'>
$timeSlotFourJobFourChk
</div>
<div class='form-check pl-5 pt-2 mb-0 time-slot'>
$timeSlotFiveJobOneChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotFiveJobTwoChk
</div>
<div class='form-check pl-5 pt-0 mb-0 time-slot'>
$timeSlotFiveJobThreeChk
</div>
<div class='form-check pl-5 pb-2 mb-2 time-slot'>
$timeSlotFiveJobFourChk
</div>
<div class='form-check pl-5 py-2 mb-2 time-slot'>
</div>
</div>";
echo $schedule_block_job_one;
}//END WHILE
?>
</div> <!-- ./row -->
</div> <!-- ./modal body -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- END SCHEDULE TIMESLOT MODAL -->
<?php
$schedule_block = "
<div class='col p-2 pb-4 m-1 bg-light shadow-sm'>
<h6 class='text-center'>{$day_of_week}</h6>
<h6 class='text-center'>{$full_date}</h6>
<hr>
<div class='col-12 text-center'>
<button type='button' data-id='$idDate' data-toggle='modal' data-target='#selectDate$idDate ' class='btn btn-sm btn-primary'>Select</button>
</div>
</div>";
echo $schedule_block;
} // end while
**这里是我尝试从模式中捕获信息以在此处插入/更新到数据库中的地方**
if (isset($_POST['slotOneJobOne'])) {
$schedule_query = "UPDATE jobschedule_101 SET ";
$schedule_query .= "slotOneJobOne = '{$timeSlotOneJobOneChk }' , ";
$schedule_query .= "slotOneJobOneCustId = '{$the_cust_id }' , ";
$schedule_query .= "slotOneJobOneStandardJobId = '{$standard_job_id }' , ";
$schedule_query .= "slotOneJobOneAssemblers = 'none' ";
$schedule_query .= "WHERE idDate ='$idDate' ";
$confirm_sechedule_query = mysqli_query($connection, $schedule_query);
confirm($confirm_sechedule_query);
} // end ifset slotonejobone
正如我所提到的,这是我唯一被困住的地方,任何帮助将不胜感激..如果我需要提供更多信息或更多详细信息,请告诉我。
非常感谢:) <3