Something is breaking this script

ScottDM 16-04-2018

I've got a dead simple script that hides and shows a subform based on the value of a checkbox:

if (this.rawValue == 1) {

form1.Page.NextYearSubform.NYSubform.presence = "visible";

}

else {

form1.Page.NextYearSubform.NYSubform.presence = "hidden";

}

This works fine if it is the first event upon opening the form. But if any other click event fires (the form has lots of checkboxes and radio buttons), this script ceases to work. Anyone seen this before?

Thanks.

Mark Solution

Are these answers useful?
Help other community members by marking useful answers as accepted.

Accepted Solutions (0)

Answers (7)

Answers (7)

ScottDM 16-04-2018

I've never needed quotes before, and like I said the script obviously runs because the xfa.host.messageBox statement works.

So it's something in the form that is preventing the script from setting the presence property of the subform. Perhaps something is scrambled in the XML, which I would be useless at debugging.

Not a big deal... I've worked around it by removing the objects from the subform.

Thanks.

ScottDM 16-04-2018

I can test it with messageBox, so I know the script executes, but the property doesn't get set.

if (this.rawValue == 1) {

xfa.host.messageBox("One");

form1.Page.NextYear.NYSubform.presence = "visible";

}

if (this.rawValue == 0) {

xfa.host.messageBox("Zero");

form1.Page.NextYear.NYSubform.presence = "hidden";

}

MinusZero 16-04-2018

So there is no confusion in livecycle, i always make sure when i have if (this.rawValue == 1) that i always have if (this.rawValue == 0) rather than just an else.

ScottDM 16-04-2018

I fixed it by referencing the objects directly rather than hiding/showing the subform that contained them:

if (this.rawValue == 1) {

Title.presence = "visible";

Grade.presence = "visible";

Year.presence = "visible";

}

else {

Title.presence = "hidden";

Grade.presence = "hidden";

Year.presence = "hidden";

}

...But if anyone can explain why hiding/showing the subform didn't work I'd like to know.

Thanks.