Table rows functionality with passing data and instances | Community
Skip to main content
Level 3
November 10, 2013
Solved

Table rows functionality with passing data and instances

  • November 10, 2013
  • 13 replies
  • 9731 views

My form setup is as follows:

I have several check boxes overlaid on an image. Each box will have several actions associated to it (more on this in a minute).

I have a Table that will take in some data, depending on what check boxes are checked and unchecked.

Several things are happening as follows:

A table is setup with the following headers and respective rows - vial#(txt), location(txt), area(txt), amount(dropdown), price(dropdown), cost(calculated - eval(amount * price)).

When a check box is selected the following actions ensue:

location and area are filled with text values [ Condition: when box FR0 is checked;  Result: set value of location to be some text, value of amount to be some text, set vocus on amount ]

When a check box is unselected the following actions ensue:

all fields are set to null.

NOTE: this actions work great with the first checkbox.

Now the issue at hand:

When the next checkbox is selected, what should happen is this: a new instance of the rows should appear, location and area should be automatically filled out in same manner as above and focus should be set on amount.

What happens is this: a new instance is created, focus is set on amount, but the 2 fields are not populated as in above example.

Next: When the other checkbox is unselected, the following should happen: the latest instance should dissapear and all cell values of last instance should be null.

What happens is this: the last instance goes aways but all the vlaues on original row (text only) also are set to null.

Now I know this setup is a mere issue with how I have my Table and subforms setup. So here is the setup of the form (also note images):

Row1 is under a Subform Values_subsection. Type: use all subforms in order / Binding: repeat section for each data item

Row1 has: Allow page breaks with content / Binding: repeat row for each data item

So where am I going wrong?

Thanks for all the help and suggestions in advance

Shai

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by _Bruce_Robertson

Hi Shai,

I think what you are trying to do is not supported by the action builder.  But can be done with your own scripting, I have added a script object which contains a custom script that will do what you want, I called it "Script" (see image below).  Select this object and then "All Events" under show in the script editor (ctrl-shift-f5) to see what I have done.

This now means that each checkbox change event needs the following JavaScript code;

Script.Change(this.rawValue, "FR 1", 100);

The first parameter is the value of the check box (1 for selected, 2 for unselected), the second the location, and the third the amount).

The Change funtion in the Script object looks like

function Change(newValue, location, amount)

{

    if (newValue == "1")

    {

      var newRow = Patient_info.Table1._Data.addInstance(1);

      if (xfa.host.version < 8) {

        xfa.form.recalculate(1);

      }

      newRow.loc.rawValue = location;

      newRow.amt.rawValue = amount;

      xfa.host.setFocus(newRow.amt);

    }

    else

    {

        var rows = Patient_info.Table1.resolveNodes("Data[*]");

        for (var i = 0; i < rows.length; i++)

        {

            var row = rows.item(i);

            if (row.loc.rawValue == location)

            {

                Patient_info.Table1._Data.removeInstance(row.index);

                break;

            }

        }

    }

}

You should see some similarity with what action builder produced.

I have only done the first row of checkboxes (the first four), but here is my version of your form I modified to check the above code worked.

https://workspaces.acrobat.com/?d=7j8MuoO37xAttiE8Q0N69Q

You may have to reselect the image of the face again as this was not included in the form you uploaded.

Hope this helps

Bruce

13 replies

_Bruce_Robertson
Level 10
November 15, 2013

Hi Shai,

That is a strange warning message to get in Acrobat, that is the sort of message I would expect with Reader if the form has not been extended.

Not sure about your SUM expression, that seems to be a new part to your form, maybe you will have to share the for again.

Bruce

ShailevitAuthor
Level 3
November 16, 2013

So here is the new and improved form. I implemented the new changes to

the Table1, where every check box does now behave as predicted with new

instances and fields are filled appropriately.

So new issue is how to script a JavaScript (as oposed to FormCalc) in

calculating all the amount fields in the table. I have it working using

formcalc eventhough it throws an error.

Other issue(s):

Form does not allow printing or saving - very odd indeed.

And how can I calculate a follow-up date via JavaScript, taking into

account the Date of Service date (DOS) field.

Here again is the link to the latest form:

https://workspaces.acrobat.com/?d=HzjISs2OjunTwvL9o6F0fA

https://workspaces.acrobat.com/?d=HzjISs2OjunTwvL9o6F0fA

<cid:part1.02080408.00040707@yahoo.com>

Thanks in advance

Shai

_Bruce_Robertson
Level 10
November 17, 2013

Hi,

The SUM expression is failing because those fields have not yet been added to the form, so if you check for their existance first you should be ok.

if (Exists(Patient_info.Table1.Data[0].amt[0])) then

    $ = Sum(Patient_info.Table1.Data[*].amt[*].rawValue)

endif

So you can still stick with FormCalc.

You can calculate a day in the future based on the Date Of Service, using (for example using 14 days);

Num2Date(Date2Num(Invoice_info.DOS, "YYYY-MM-DD") + 14)

I've updated the form with these two changes, https://workspaces.acrobat.com/?d=7j8MuoO37xAttiE8Q0N69Q

Not sure about why the form can not be printed or saved.  Can you save/print other forms, or even other PDF's.  I have Acrobat XI (11.0.5) and Reader X (10.1.8)

Bruce