Hi All,
I have a print button that calls a custom print service via Javascript. Is it possible to get the code to wait for a reply from the custom service before continuing? Or, is it possible to put a Wait or Delay in the Javascript?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Garreth,
The attached demonstrates the JavaScript equivalent of Num2Time.
FormCalc
// form1.page1.formCalc::initialize - (FormCalc, client)
$.rawValue = Num2Time(Time(), "HHMMSS")
JavaScript
// form1.page1.javaScript::initialize - (JavaScript, client)
var d = new Date();
this.rawValue = myScriptObject.pad(d.getHours()) + myScriptObject.pad(d.getMinutes()) + myScriptObject.pad(d.getSeconds());
Since the time getters return a single integer if value < 10, I created a script object to pad the value with a leading 0 (zero),
// form1.page1.#variables[0].myScriptObject - (JavaScript, client)
function pad(n) {
return (n < 10 ? '0'+ n : n)
}
Steve
Views
Replies
Total Likes
The attached form enables a wait time. It uses 2 hidden fields, one to capture the time the button is clicked and a second to calculate the current time. The script on the button click event is as follows:
// form1.subform1.btn::click - (JavaScript, client)
form1.subform1.timeAtClick.execEvent("calculate");
var endTime = parseInt(form1.subform1.timeAtClick.rawValue) + parseInt(form1.subform1.waitTime.rawValue);
var currentTime = 0;
while (currentTime < endTime) {
form1.subform1.currentTime.execEvent("calculate");
currentTime = parseInt(form1.subform1.currentTime.rawValue);
}
xfa.host.messageBox("Done waiting " + form1.subform1.waitTime.rawValue + " seconds.","Timer",3,0);
Hi Steve,
Many thanks for your reply.
Since I am using a form guide I cannot use the FormCalc behind timeAtClick and currentTime. Do you know how to code Num2Time(Time(), "HHMMSS")
in JavaScript?
Garreth
Views
Replies
Total Likes
Hi Garreth,
The attached demonstrates the JavaScript equivalent of Num2Time.
FormCalc
// form1.page1.formCalc::initialize - (FormCalc, client)
$.rawValue = Num2Time(Time(), "HHMMSS")
JavaScript
// form1.page1.javaScript::initialize - (JavaScript, client)
var d = new Date();
this.rawValue = myScriptObject.pad(d.getHours()) + myScriptObject.pad(d.getMinutes()) + myScriptObject.pad(d.getSeconds());
Since the time getters return a single integer if value < 10, I created a script object to pad the value with a leading 0 (zero),
// form1.page1.#variables[0].myScriptObject - (JavaScript, client)
function pad(n) {
return (n < 10 ? '0'+ n : n)
}
Steve
Views
Replies
Total Likes
Hi Steve,
Thank you for your help. It work a charm.
Garreth
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies