Expand my Community achievements bar.

SOLVED

Newbie help - Auto population

Avatar

Level 2

Hello, I have a contact information (general information) subform and a billing information subform. Is there a way to add a radio button that says "Same as General Information? This would help so that our customers don't have to retype name, address, email, etc.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Not naming subforms and objects is really hurting you here. It makes it so much more difficult to script.

Here is the form back to you:

https://acrobat.com/#d=MWWzrKO0Xqr0YvYEAq72nQ

You will see that I have named the billing information subform. If you look at the script in the click event of the checkbox, you can see that the objects on the left are so easy to reference now. However because the objects on the right are still in an unnamed subform, each reference needs to be resolved. It works, but is a pain.

So I would recommend that you name subforms, pages and objects as you go, as this will make scripting a breeze.

Also have a look at the script in the exit event of the general information fields, as the reference to the checkbox is now correct.

See an example here on referencing objects: http://www.assuredynamics.com/index.php/category/portfolio/referencing-objects/

Good luck,

Niall

Assure Dynamics

View solution in original post

8 Replies

Avatar

Correct answer by
Level 10

Hi,

Not naming subforms and objects is really hurting you here. It makes it so much more difficult to script.

Here is the form back to you:

https://acrobat.com/#d=MWWzrKO0Xqr0YvYEAq72nQ

You will see that I have named the billing information subform. If you look at the script in the click event of the checkbox, you can see that the objects on the left are so easy to reference now. However because the objects on the right are still in an unnamed subform, each reference needs to be resolved. It works, but is a pain.

So I would recommend that you name subforms, pages and objects as you go, as this will make scripting a breeze.

Also have a look at the script in the exit event of the general information fields, as the reference to the checkbox is now correct.

See an example here on referencing objects: http://www.assuredynamics.com/index.php/category/portfolio/referencing-objects/

Good luck,

Niall

Assure Dynamics

Avatar

Level 2

I see exactly what you mean. So I can leave this form as is (thank you for correcting this) or I can go back, name the first subform and then change the info on the right side of the If statement. So instead of:

xfa.resolveNode("#subform.CompanyorInstitution_Contact").rawValue;

I could change each of these to:

general.CompanyorInstitution_Contact.rawValue;

Is this correct assuming I call the first subform "general"? I'm just a little hazing on how  to reference a specific field. I get that the left side only needs the fields name because the check back is within that subform, but the other lines need to reference a different subform, then a specific field.

Thanks again,

Tim

Avatar

Level 10

That's correct!!!

I would recommend correcting it and naming the LHS subform generalInfo.

Come back if you run into trouble

Niall

Avatar

Level 2

Niall, since you were so helpful on answering that question. I thought I would hit you up with one more. One page 2 of my form, how do I get the "Total Samples on this Page" to auto-populate with the number of rows that are filled out. I don't need a validation of the data just need to know if any part of a part is filled out.

I tried instanceManager.count but I'm really confused on this.

Avatar

Level 10

No problem Tim, but I'm out of the office. I'll have a look tomorrow.

Niall

Avatar

Level 10

Hi Tim,

Again naming objects is recommended. I have picked the Sample ID as the object you are going to check on each row. If this object is non-null then it will be counted.

You have two pages with this table, so on page 2 I have set up a FormCalc function "Count()", which goes to each row in turn and checks the Sample ID field.

When looping through a table it is often very useful to have the rows with the same name: eg, Row1. You will see in the hierarchy on page 3 that LC Designer automatically inserts the instance number for each row: Row1[0], Row1[1],... ,Row[11]. This is based on a zero numbering system. Again on page 3 we use the FormCalc function "Count()', but the script is simpler because we can reference each instance of the Sample ID field using the wildcard *.

The script in the calculate event of the Total Samples fields on page 2 and page 3 are slightly different (showing two approaches), but both work so you can pick which solution suits you best.

Here is the link to the updated file: https://acrobat.com/#d=MWWzrKO0Xqr0YvYEAq72nQ

Good luck,

Niall

Assure Dynamics