简体   繁体   中英

Adobe Livecycle Javascript Overall Logic for Simple Show Hides

I'm attempting to use a large amount of simple show/hide scripts in Adobe Live Cycle to combine a few forms into one. I'll be layering text entry fields on top of each other and have them all start as invisible (using Live Cycle's invisible settings). The showing/hiding of these objects will be controlled through use of a drop down list.

The basic task would be:

-Click an item from  a dropdown list.
-Initiate a show of relative invisible elements on the page based on the 
 raw value of the item selected.
-If user changes dropdown value, hide previously displayed data and show new
 corresponding data.

Can this all be accomplished from inside the dropdown list itself? I've inherited this project from a previous developer, so I'm cobbling together some of his code and attempting to get a grip on what actually needs to be done so that I can accomplish the task. Here is an example of what the show hide structure looks like:

xfa.resolveNode("form1.#subform.indPaymentOptions").selectedIndex = 0;
xfa.resolveNode("form1.#subform.VendPaymentOptions").selectedIndex = 0;
xfa.resolveNode("form1.#subform.Display_Field_Pay_Types").rawValue = 
    "Please select an option from the 'Select type' drop-down menu above.";
taxReportable.rawValue = "";
AccountCodesDynamic.rawValue = "";

if (xfa.resolveNode("form1.#subform.payeeType").rawValue == 2) {
    xfa.resolveNode("form1.#subform.indPaymentOptions").presence = "visible";
    xfa.resolveNode("form1.#subform.VendPaymentOptions").presence = "hidden";
}

else if (xfa.resolveNode("form1.#subform.payeeType").rawValue == 3) {
    xfa.resolveNode("form1.#subform.indPaymentOptions").presence = "hidden";
    xfa.resolveNode("form1.#subform.VendPaymentOptions").presence = "visible";
}
else if (xfa.resolveNode("form1.#subform.payeeType").rawValue == 1) {
    xfa.resolveNode("form1.#subform.indPaymentOptions").presence = "hidden";
    xfa.resolveNode("form1.#subform.VendPaymentOptions").presence = "hidden";

}

All the code above seems pretty straightforward, but there is also some code in the initialize section of the document:

    if (xfa.resolveNode("#subform.RadioButtonList[2].ind").rawValue == 1)
    indPaymentOptions.presence = "visible";

else if (xfa.resolveNode("#subform.RadioButtonList[2].vend").rawValue == 2)
    vendPaymentOptions.presence = "visible";

I'm curious to know if this sort of thing is necessary. If it is, could someone please explain to what extent such code is needed in the initialize section of the document?

If it isn't necessary, is the show/hide coding that I pasted at the top of this post sufficient for what I'm trying to accomplish?

I've tried slogging through Adobe's livecycle documentation, but it is difficult to find a broad overview of what is necessary, so I'm having difficulty making use of it. Any help is greatly appreciated. If there is a resource I'm missing I would love to teach myself how to do this. Also, this is my first post here. I did my best to follow the submission guidelines in the FAQ, but apologies in advance if I violated any submission guidelines. Thanks.

The code for the drop-down looks pretty straight forward and should be fine (although you will probably find after using LiveCyle for a while, even some of the simpler tasks with logical code don't work).

The code in the initialize event is actually for a radiobutton group rather than the drop-down so it's possible that the functionality of the visible forms is actually driven by more than just the drop-down.

What you tend to end up with in LC is the code for a change or validate event being repeated in the initialize event so that when the form opens it displays/processes correctly. This can of course be worked around by invoking an event with the code from the object's other eventsevent. eg. in the Drop-down initialize event you would hold the dropdown code and in the change event of the dropdown you would use this.execEvent("initialize") which would call the code when the change event is triggered.

It's a little difficult to get a view of what's happening in your particular case without seeing the form but let me know if anything isn't clear or I can help with anything else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM