부트 스트랩 모델 입력 상자에 자바 스크립트 변수로드에 문제가 있습니다.
setTimeout(function() {
swal({
title: "OverTime Status!",
text: "You Need to get Sub OT Approval " + data.value + " Hours to Time allocate in the department",
type: "warning",
confirmButtonText: "OK"
},
function(isConfirm) {
if (isConfirm) {
$('#hours_work').val(data.value); //data.value alert the correct value in here.but this value not load in to the bootstrap model text box
$('#overtime_requset').modal('show');
clear_field();
}
});
}, 1);
<div class="modal" id="overtime_requset">
<div class="modal-dialog ">
<form id="overtime_requset_form">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Sub OT Request</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="form-group">
<div class="input-daterange">
<input type="text" name="from_date" id="from_date" class="form-control" value="<?php echo $_GET[" month "]; ?>" readonly />
<span id="error_from_date" class="text-danger"></span>
<span id="error_future_from_date" class="text-danger text-center"></span>
</div>
</div>
<div class="form-group">
<label class="text-info">Tolal Number Of Employee <?php echo get_total_employee_count($connect,$_SESSION["dept_Id"])?></br>
<label>Add the addition number of OT hours requried</lable>
<input type="text" name="hours_work" id="hours_work" class="form-control" value=""/>
<label class="text-secondary">Approved OT hours : <?php echo GetApprovedOt($connect,$_SESSION["dept_Id"],$currentMonth)?></br></label><br>
<label class="text-secondary">Pendding OT hours : <?php echo GetPendingOt($connect,$_SESSION["dept_Id"],$currentMonth)?></label>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" name="get_approval" id="get_approval" class="btn btn-info btn-sm">Get Approval</button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Close</button>
</div>
</div>
</form>
</div>
</div>
data.value는 여기에 올바른 값을 경고합니다. 그러나이 값은 부트 스트랩 모델 텍스트 상자에로드되지 않습니다. 내 실수는 무엇입니까? 어떻게 고치나요? (문제는 텍스트 필드에 JavaScript 값을로드하지 않는 것입니다. div 태그에 HTML로 인쇄 할 수 있습니다)
cdn sweetAlert boostrap에 따라 업데이트했습니다.
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.css" />