I have two javascript functions and i have a submit button for each function , whats the best implentation to add a few seconds wait between the two functions for example in javascript.
setTimeout(function(){
//do what you need here
}, 5000);
I have searched for other examples but those did not fit this purpose.
I have two scripts.
The one below writes text inputed to a text file.
function SaveData() {
var oFSO = new ActiveXObject("Scripting.FileSystemObject");
var folder = "C:\\Temp";
var filePath = folder + "\\Test.txt";
if (!oFSO.FolderExists(folder)) { oFSO.CreateFolder(folder); }
var oFile = oFSO.CreateTextFile(filePath, true);
var output =
"STORE_NAME=" + STORE_NAME.value + "\r\n" +
"STORE_NUMBER=" + STORE_NUMBER.value + "\r\n" +
"EPM_NUMBER=" + EPM_NUMBER.value + "\r\n" +
"MCID=" + MCID.value + "\r\n" +
"SCREEN_SN=" + SCREEN_SN.value + "\r\n" +
"customer_name=" + customer_name.value + "\r\n" +
"scanner_type=" + scanner_type.value + "\r\n";
oFile.Write(output);
oFile.Close();
//alert("Saved to " + filePath);
}
And the other opens a batch file with the data from the text file generated by the above.
I did try adding the setTimeout function to the script above but it ignored it.
I have two buttons below.
I have tried the below and it does work but would prefer to have a few seconds between them.