how to load java script variable in to the bootstrap model text box as value
Try this. I think function(isConfirm)
is problem.
You need use then() function
swal({
title: "OverTime Status!",
text: "You Need to get Sub OT Approval " + data.value + " Hours to Time allocate in the department",
type: "warning",
showCancelButton: false
}).then(function (result) {
$('#hours_work').val(data.value);
$('#overtime_requset').modal('show');
});
For form input fields you need to use val()
instead of text()
.
Example: $('#hours_work').val(data.value);
your posted code is bit lacking and has some errors, anyways i tried to replicate your problem and i think i may have gotten it working. Take a look at below jsfiddle snippet and see if you can implement in your code to get it working.
CHECK OUT THIS LINK FIRST: https://jsfiddle.net/b1nary/je60gxv8/2/
UPDATED WITH YOUR SWEETALERT: https://jsfiddle.net/b1nary/je60gxv8/11/
setTimeout(function() {
swal({
title: "OverTime Status!",
text: "You Need to get Sub OT Approval " + data_val + " Hours to Time allocate",
type: "warning",
showCancelButton: true,
confirmButtonText: "Yes, do it",
closeOnConfirm: false,
html: false
}, function(){
swal("Deleted!",
"Poof! Your number has been added to input box!",
"success");
$('#hours_work').val(data_val);
$('#overtime_requset').modal('show');
//clear fields
});
}, 1000 );