Skip navigation
Currently Being Moderated

PrePrint

Jul 10, 2012 11:15 AM

How would I script a prePrint event if I don't want a subform to print if the fields inside it are empty?

 
Replies
  • Currently Being Moderated
    Jul 10, 2012 12:02 PM   in reply to jeanette614

    Hi,

     

    to prevent user from printing you can use the validate element in the config DOM.

    Here's an article which descibes how to use it.

     

    http://forms.stefcameron.com/2008/04/13/prevent-printing-pdf-forms-in- acrobat-8/

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 10, 2012 3:29 PM   in reply to jeanette614

    Hi,

     

    I use a function like the one below to test for a subform containing empty fields, so you could pass in the subform and if you get a true response set the presence property of the subform to "hidden".

     

    function isNull(node)

    {

        //Debug.trace(arguments);

        var result = true;

        switch (node.className)

        {

            case "exclGroup":

            case "field":

                result = node.isNull;

                break;

        }

        for (var i=0; i<node.nodes.length && result; i++)

        {

            var childNode = node.nodes.item(i);

            if (childNode.isContainer && childNode.className !== "draw" && childNode.className !== "variables")

            {

                result = isNull(childNode);

            }

        }

        return result

    }

     

    Depending on how complicated your subform is it might just be simplier to test the fields individually.

     

    Bruce

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points