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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
So two ifs rather than an if with an else.
Is else known to be unreliable?
Views
Replies
Total Likes
I tried it with two ifs and it still wouldn't set presence = "visible".
Very strange.
Views
Replies
Total Likes
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";
}
Views
Replies
Total Likes
Weird.
Do you need to have quotes around the value?
When you use the action builder, it uses quotes.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies