Skip navigation
Currently Being Moderated

If statement, when true, runs two actions

Apr 18, 2012 11:39 AM

Tags: #form #livecycle_designer_es

How do I write an if statement that when true, runs two actions?

 

if (NumericField1.rawValue > 0)

{

    xfa.resolveNode("#pageSet.Page1.Image1").presence = "visible" + Rectangle1.presence = "visible";

}

 
Replies
  • Currently Being Moderated
    Apr 18, 2012 12:03 PM   in reply to DKinsley

    Generally all actions should be written in a separate code line:

     

    if (NumericField1.rawValue > 0) {

        xfa.resolveNode("Image1").presence = "visible";

        xfa.resolveNode("Rectangle1").presence = "visible";

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 1:10 PM   in reply to DKinsley

    Try

     

    if (xfa.resolveNode("form1.#subform.#subform[1].NumericField1").value.on eOfChild.value > 0) {

                xfa.resolveNode("form1.#subform.#subform[1].Rectangle1").presenc e = "visible";

    }else{

              xfa.resolveNode("form1.#subform.#subform[1].Rectangle1").presenc e = "invisible";

              }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 11:30 PM   in reply to DKinsley

    Well, the problem is you're trying to control objects on the body page and a masterpage at once.

    This is generally not so simple to accomplish.

     

    I changed your form a bit.

    The paperclip image and the numeric field now monitor the valur of the numeric field and change the wanted property if the value is larger than 0.

     

    Script for the paperclip (wrapped in a subform)

    form1.Page.#subform[0].NumericField1::ready:layout - (JavaScript, client)

     

    this.ui.numericEdit.border.fill.color.value = this.rawValue > 0 ? "255,255,153" : "255,255,255";

    Script for the numeric field

    form1.#pageSet[0].Page1.Clip::ready:layout - (JavaScript, client)

     

    this.presence = xfa.resolveNode("Page.#subform.NumericField1").rawValue > 0 ? "visible" : "hidden";

     

    Script for the remove button

    form1.Page.#subform[0].Button3::click - (JavaScript, client)

     

    var myDoc = event.target;

    var sFile = ListBox1.getDisplayItem(ListBox1.selectedIndex);

     

    try {

              if (sFile !== "") {

                        var nResponse = xfa.host.messageBox("You are about to delete the highlighted attachment. \n\nDo you want to continue?", "Deleting an Attachment", 1, 2);

                        if (nResponse == 4) {

                                  myDoc.removeDataObject(sFile) + ListBox1.deleteItem(ListBox1.selectedIndex) + (NumericField1.rawValue = NumericField1.rawValue - 1);

                        }

              } else {

                        xfa.host.messageBox("No document selected.");

              }

    } catch (e) {

              xfa.host.messageBox("Error in removing document");

    }

     

    https://acrobat.com/#d=55A3x-8Zm7D29eK7*brqxQ

     
    |
    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