Hi, I’m creating a document with multiple forms. I’m having issues with combining the natural mother’s name and natural father’s name in a field.
On one form the names are three separate fields so I have named the fields as follows for mom’s complete name: NMFirst, NMMiddle, NMLast.
I did the same for the father’s name: NFFirst, NFMiddle, NFLast.
On another form there is one field for each parent’s complete name. For the mother I combined all three fields into one, naming that field NMName.
Again the same was done for the father, I named that field NFName.
Here is where I have run into an issue. Another form is a letter and in the address block it should have the mother’s complete name and the father’s complete name.
This is my coding:
var nm = this.getField("NMName").valueAsString; //natural mother’s full name
var nf = this.getField("NFName").valueAsString; //natural father’s full name
if (nf =="")event.value = nm; //if no natural father, show natural mother’s name only
else event.value = nm + " and " + nf; //this should show natural mother’s name and natural father’s name
This works fine until there is no natural father’s name and the result is the natural mothers name and the word “and”
Example: Megan Michelle Wright and
I’ve been looking at this for a while and trying different things to remove the word “and” but I think I’m just stuck. Thank you.
Use this code:
if (nf=="" && nm=="") event.value = ""; //if nothing is entered, show nothing
else if (nf=="" && nm!="") event.value = nm; //if no natural father, show natural mother’s name only
else if (nf!="" && nm=="") event.value = nf; //if no natural mother, show natural father’s name only
else event.value = nm + " and " + nf; // show both
Hi try67m thank you for the code you provide, however I get the same result of: Megan Michelle Wright and
when there is no father's name
That's strange... Are you sure the field is completely empty? If it has even a single space character in it, it's no longer considered empty.
Also, where did you place the code?
Yes, the field is empty and I placed the coding under the Custom calculation script area of the Calculation tab of the text field property.
Can you share the file with us (via Dropbox, Google Drive, Adobe Cloud,
I just did a test and when I use only the mother's first name (NMFirst) and father's first name (NFFirst) fields the coding works.
But if I use the fields (NMName and NFName) that combines all 3 names (first, middle and last) the code didn't work.
Do those fields have a calculated value? If so, check the fields calculation order.
Also check the JS Console for error messages.
Hi try67, I changed the calculation order and opened the JS Console but wasn't sure what I was looking at or for.
I'm unable to share the file via Dropbox, Google Drive, Adobe Cloud. I have an IT department that has limited our use of certain software.
I stepped away from this file on Friday and have picked it up again today to see if I could get the coding to work but still a no go.
Well, after changing the value of one of the fields check the JS Console for error messages. They should appear in the lower part of the window. If there aren't any then that's good.