These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to make dropdown time field show time.

praymond
Registered: Jun 15 2010
Posts: 4
Answered

Do I have to manually enter all time values in item box ?

There must be an easier way.

Can you save or import to item box ?

Thanks

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You can populate the file with the current time through a FormCalc script.

Such as:
$ = Num2Time(time(), "HH:MM:SS")

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

praymond
Registered: Jun 15 2010
Posts: 4
Thanks, that worked to put the current time in and I have taken note.

But what im attempting to do is have a dropdown that user can pick a time without have to input all the hours and minutes manually. Even if it is not exactly minutes they can be rounded to the quarter.
example below

1:00
1:15
1:30
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You can write a script that populates the time in the list, but believe me, this will take much more time than adding the values by hand.
If you enter all times with an interval of 15 minutes how long will you need? It's about 2 minutes to type them all into the drop down list, that's even faster than writing this reply ;-)

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
OK,

to make it easier I made a JavaScript, that will do the job for you.
Put it into the initialize:event of the drop down field.

var Hours = "00/01/02/03/04/05/06/07/08/09/10/11/12/13/14/15/16/17/18/19/20/21/22/23".split("/");var Minutes = "00/15/30/45".split("/"); var Times;for (h = 0; h < Hours.length; h ++){for (m = 0; m < Minutes.length; m ++){Times = Hours[h] + ":" + Minutes[m];this.addItem(Times);}}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

jonom
Registered: Jan 31 2008
Posts: 133
Hey Radzmar, great little script!

The "h" variable is causing an error though as I think it's reserved (height measurement). I changed the "h"s to "i"s and the script ran fine.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

you're right, the h variable may be a problem.
I redesigned the script a bit, so you don't need to enter the times before.

//Interval in Minutesvar Interval = 5var Time; for (hrs = 0; hrs < 24; hrs ++){for (min = 0; min < 60/Interval; min ++){hh = hrs.toString();if(hh.length < 2){hh = hh.replace(hh, "0" + hh);}temp = min * Interval;mm = temp.toString();if(mm.length < 2){mm = mm.replace(mm, "0" + mm);}Time = hh + ":" + mm;this.addItem(Time);}}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

praymond
Registered: Jun 15 2010
Posts: 4
Thanks a heap, I really appreciatte it.

Patrick :-)