Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

setTimeout

Avatar

Former Community Member
HI, please i would like to know how can i call to a function every 1 sec.

i try to put the real time in my form? I put this in the initialize event of a text field named "TimeNow" , I know to make it worked one time but every sec no, hoe can i make it with(setTimeout or setInterval) ?

thanks in advenced,



function startTime()

{



var today=new Date()

var h=today.getHours()

var m=today.getMinutes()

var s=today.getSeconds()

// add a zero in front of numbers<10

m=checkTime(m)

s=checkTime(s)

page1.header.TimeNow.rawValue=h+":"+m+":"+s;



//t=setTimeout('startTime()',500)

}

function checkTime(i)

{

if (i<10)

{i="0" + i}

return i

}



startTime();
1 Reply

Avatar

Former Community Member
Put your function in a script object, let's say it's named so. On the doc:ready event of your form object put this script:



var myInterval = app.setInterval("xfa.form.form1.variables.so.startTime();", 1000);



Assuming your form object is named form1.



Then on the doc:close event of the form object put:



app.clearInterval(myInterval);



Chris

Adobe Enterprise Developer Support