Expand my Community achievements bar.

Button to copy all fields

Avatar

Level 3

HI,

I would like to create a button on a form...when the user clicks this button, all of the field values are copied and pasted into a big text field on the form.

Doesn't have to be pretty, I just want all the data from many fields dumped into one field.

Many thanks,

Joe

1 Reply

Avatar

Level 6

If an xml format is fine with all field and values then on the button click can assign the xml to a field(field name is: completeData).

var formDataStr = xfa.datasets.data.saveXML("pretty");

  completeData.rawValue = formDataStr;

If need ONLY fieldname and/or values can go by script function and get the values of each n every field on the form.

call "traverse" function on click of the button and pass "oParentNode" as the rootname of the form.

function traverse(oParentNode)

{

          var allChildElements;

          var intNumElements;

          var currentElement;

          var i;

          var j;

          // Get all occurances of the parent element

          intNumOccurances = oParentNode.all.length;

          for (i=0; i < intNumOccurances; i++)

          {

                    oCurrentParent = oParentNode.all.item(i);

                     // Get all the child nodes of the parent element

                    allChildElements = oCurrentParent.nodes;

                    // Total number of elements in the object

                    intNumElements = allChildElements.length;

                    // Loop through all the child elements

                    for (j=0; j < intNumElements; j++)

                    {

                              currentElement = allChildElements.item(j);

                              // If the element is another subform we'll recursively call the function again

                              if (allChildElements.item(j).className == "subform")

                              {

                                        traverse(currentElement);

                                        // If the objects are fields or exclusive groups then we'll encode them

                              } else {

                                        if (currentElement.className == "field" || currentElement.className == "exclGroup")

                                        {

                                                  //Here have the access for both field and value

                                  //your code comes here

                                                  fields += currentElement.name + "\t";

                                                  values += currentElement.rawValue + "\t";

                                          }

                              }

                    }

          }

}          // end traverse function

Hope this will help.