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

If field1 is empty, field2's font is white, if field2 is NOT empty, field2's font is black ??

poregon
Registered: Oct 27 2008
Posts: 80
Answered

Anybody have a quick way to do this?
I have a field (field2) that is calculating +90 days from field1. Since it displays DD/MM/1900 before calculating, I want it in white font in order to not show.
Or would there be a better way with visible/hidden or something else?
 
Thanks again everyone.

poregon
Salix, Iowa

My Product Information:
LiveCycle Designer, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
I think a better approach would be to set the field value to nothing in the calculation if the field1 value is nothing.
poregon
Registered: Oct 27 2008
Posts: 80
You lost me, George - can you show me an example based on my scenario?

poregon
Salix, Iowa

poregon
Registered: Oct 27 2008
Posts: 80
Here's my calculation that is in Field2

$ = Num2Date(Date2Num(Beginning, "MM/DD/YYYY") + 365, "MM/DD/YYYY");

So, prior to entering anything into Date2 (what I've been calling Field1), Field2 displays 12/31/1900.

I just don't want that to show prior to entering the date in Date2 (which, by the way is a numeric field, not a date field).

poregon
Salix, Iowa

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Is Field1 named "Date2" or "Beginning"? What I'm saying is you should use an if/then block. Test the value in Field1, and if it's blank, set the value of the field in the calculation to nothing. Otherwise set it like you currently do.
poregon
Registered: Oct 27 2008
Posts: 80
I'm sorry, George - it's "Beginning".
I've been working on an if/then block, but threw in the towel and looked for a different approach, hence the font change idea.
Would you be willing to correct my work, here George? Here's as far (or close) as I could get, but it obviously isn't working. The second field is "Ending".

if (Beginning.rawValue == null) then
$.presence = "invisible";
else
$.presence = "visible";
endif

Since I already have a FormCalc calculation going on in "Ending" (the one above), how would I put my if statement (once you can show me where I'm wrong on it) in the same "Ending" field if the "if" statement is in JavaScript, while the calculation is in FormCalc?

poregon
Salix, Iowa

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Here's what I was thinking:

if (Beginning.rawValue) then
$ = Num2Date(Date2Num(Beginning, "MM/DD/YYYY") + 365, "MM/DD/YYYY")
else
$ = null
endif

I don't know if your calculation code will work, because I don't understand using Date2Num on numeric value, but you should get the idea.

The reasoning is if forms are all about data, then the field values should contain valid data when possible, and not merely be hidden from the user's view if the values not valid.
poregon
Registered: Oct 27 2008
Posts: 80
you're onto something, there George. My calculation doesn't work when part of the if statement, because the if statement is in JS and the calculation only works in FormCalc.
How would you write the expression
$ = Num2Date(Date2Num(Beginning, "MM/DD/YYYY") + 365, "MM/DD/YYYY");
in JS so it results in the same results?

Everything else makes sense to me. Thanks.

poregon
Salix, Iowa

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Can you give more information about how the field Beginning is set up? The Date2Num function operates on a string that looks like a date, but you said it's set up as a numeric field.
poregon
Registered: Oct 27 2008
Posts: 80
I was wrong there, too, George. I'm sorry. "Beginning" is set up as a Text Field, same for "Ending". No display or validation patterns.

poregon
Salix, Iowa

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
OK. Sorry about that previous untested code, my FormCalc is a bit rusty since I rarely use it. I tested the following FormCalc and it should work as you want. This is the calculate code for the ending field.


if (Beginning.isNull | Beginning == "") then
$ = null
else
$ = Num2Date(Date2Num(Beginning.rawValue, "MM/DD/YYYY") + 365, "MM/DD/YYYY")
endif
poregon
Registered: Oct 27 2008
Posts: 80
That's it! This was great to learn from. Thank you so much for taking time to look at this for me. I really appreciate it. You're a good guy, George. God Bless.

poregon
Salix, Iowa

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
I'm glad it's working, but that .rawValue in the last bit of code I posted is not necessary. Sigh!