Hi,
Hope all are in good health.
In my form there are a field named "machne_no". I want to show sweetalert2 message once user input value in that text field. I wrote below javascript code fulfill my requirement.
{ // keys = event types, values = handler functions
"change": function(e) {
// Your code
//Pass the id of the <input> element to be copied as a parameter to the copy()
let copyText = (mechine_no) => {
//Selects the text in the <input> elemet
document.getElementById(mechine_no).select();
//Copies the selected text to clipboard
document.execCommand("copy");
};
var batch_id = $mysqli -> query("SELECT grd_batch_no FROM production where machine_no = copyText.value AND dyeing_started = "Yes" AND dyeing_complete = "No"")
var job_queue = $mysqli -> query("SELECT COUNT(grd_batch_no) FROM production where machine_no = copyText.value AND dyeing_started = "No" AND dyeing_complete = "No"")
var machine_occupancy = $mysqli -> query("SELECT loading_time FROM production where machine_no = copyText.value AND dyeing_started = "Yes" AND dyeing_complete = "No"") // return full datetime, eg: 2023-5-20 13:55:21
var wait_time = $mysqli -> query("SELECT SUM(MINUTE(required_hour)) FROM production where machine_no = copyText.value AND dyeing_started = "No" AND dyeing_complete = "No"")
function add() {
setInterval(() => {
// let currentTime = new Date().getTime();
let queueTime = new Date(machine_occupancy + wait_time / 60);
Swal.fire(
'Machine No: copyText.value is occupied for batch no: batch_id.value.',
'Number of batch in the job queue is: job_queue.vaule ',
'Approximately waiting time: wait_time Hours ',
'Approximately schedule time for your batch: queue_time.value: ', // want to show full datetime, eg: 2023-5-20 13:55:21
'question'
)
}
}
There are programming mistakes on my code. Can anyone help me to formulate codes on the write way?
Thanks in advance .