Expand my Community achievements bar.

SOLVED

Automatically filling in a date field upon checking a box

Avatar

Level 1

I've created a form with a number of check boxes. Each box coresponds to a different stage in a project that is checked when completed. What I'd like to do, if possible, is add a date field assinged to each check box that automatically fills in the date the box was checked.

Is this possible and if so, how?

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You have to save the form as a dynamic PDF. See the attached modified sample.

paul

View solution in original post

10 Replies

Avatar

Former Community Member

I have created a small sample for you. Please see the attached. I also hid the date fields until the checkbox is checked.

Paul

Avatar

Level 1

Thanks for the help, unfortunately I am still not able to get it to work. Could it be because I'm using an older version of LiveCycle (version 8.0)? I can get your form to run just fine but whe I duplicate the code to my form I get nothing. In fact I copied the fields you provided directly to my form and they would not work there.

Can you tell me what I'm doing wrong?

I've attached my form. Hopefully that will help.

P.S. - I also have need to add a popup on the form when it is first accessed, if you have any idea how to do it that would be great too.

Avatar

Correct answer by
Former Community Member

You have to save the form as a dynamic PDF. See the attached modified sample.

paul

Avatar

Level 1

Thanks again Paul.

Got another question for you.

I check the box and the date now shows up but when I save it and go back the box still shows as checked but the date is no longer visable. Why?

Avatar

Former Community Member

Because we have initialized the form to hide the field. We woudl need to add code to the initialize event of that field to see if the checkbox is checked and make it visible accordingly.

paul

Avatar

Level 1

Problem, I'm really new at this and my scripting ability is almost nill. I've been exposed to different scripting languages in the past so I can kind of make them out and am ok enough to know when I need to change CheckBox1 to CheckBox2 and so on but I really don't have enough knowledge to write my own scripts.

Could I get you to offer some more help and give me the code necessary to do what I need?

Thanks Paul,

Ken

Avatar

Former Community Member

On the Initialize event of the DateField you can add this code:

if (CheckBox1.rawValue == 1){

     this.presence = "visible";

}

Then you can duplicate the code for each datefield substituting the proper object values for that dateField. Note that this is Javascript

Paul

Avatar

Level 1

Beautiful !

Thank you for all the help!

Could I ask one more question? Can I add a pop up to the form? Something with a simple statement that pops up any time the form is opened.

Avatar

Former Community Member

Do you mean like a message box when the form is opened?

To do that you woudl add the command:

app.alert("This is the message");

to the initialize event of the 1st field.

Paul

Avatar

Level 1

Perfect!

You're awesome, thanks again.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----