Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Multiple Select List Box Problem

Avatar

Former Community Member
I have a multiple select list box with only 3 entries. I have been trying, with no luck, to program it so that when one specific entry is selected that a subform is made visible.



I have entry 1, 2, and 3 and if 2 is chosen then the subform is visible. I got that piece to work but if 1 and 2 or 2 and 3 or 1 and 2 and 3 are chosen then the subform is made visible otherwise it stays hidden.



For some reason I can't this to work.



Any thoughts?



Thanks in advance.



John
6 Replies

Avatar

Former Community Member
Which event is your code running on that sets the presence of the subform? I would use the exit event and not the change event.



Also make sure that your form is set to be dynamic.

Avatar

Former Community Member
Paul,



Thanks for the quick reply.



I have it in the Exit event of the List Box in a dynamic pdf file. I think my code is flawed would you be willing to review it below?



---------Begin Code-----------

if ((($.boundItem(xfa.event.newText) eq 1) and ($.boundItem(xfa.event.newText) eq 2)) or (($.boundItem(xfa.event.newText) eq 2) and ($.boundItem(xfa.event.newText) eq 1))) then

topmostSubform.Page1.Subform15and16.Section15.SubformManufAddress.presence = "visible";

elseif ((($.boundItem(xfa.event.newText) eq 3) and ($.boundItem(xfa.event.newText) eq 2)) or (($.boundItem(xfa.event.newText) eq 2) and ($.boundItem(xfa.event.newText) eq 3))) then

topmostSubform.Page1.Subform15and16.Section15.SubformManufAddress.presence = "visible";

elseif ($.boundItem(xfa.event.newText) eq 2) then

topmostSubform.Page1.Subform15and16.Section15.SubformManufAddress.presence = "visible";

elseif ((($.boundItem(xfa.event.newText) eq 1) and ($.boundItem(xfa.event.newText) eq 3)) or (($.boundItem(xfa.event.newText) eq 3) and ($.boundItem(xfa.event.newText) eq 1))) then

topmostSubform.Page1.Subform15and16.Section15.SubformManufAddress.presence = "hidden";

elseif ($.boundItem(xfa.event.newText) eq null) then topmostSubform.Page1.Subform15and16.Section15.SubformManufAddress.presence = "hidden";

endif

---------End Code-----------



Thanks!



John

Avatar

Former Community Member
That code will not work on the exit event. The xfa.event.newText will only be available to th echnage event (while the listbox has focus). Also the newText can only have one value, the last one selected. If you want to stay with the multiselect you can use the rawValue property to get waht was selected by the user. If multiple selections are choosen then you will get a rawValue of One Two. I suggest putting a message out to the screen to see what the values that you need to test are. You can do this by using an app.alert(this.rawValue) if you are using JavaScript or a xfa.host.messageBox($.rawValue) if you are using FormCalc.



Make sense?

Avatar

Former Community Member
Paul,



The message box was very helpful. I still wasn't able to perform some sort of equality check on the raw values.



The data appeared like below:

1

2



I think I was making the whole idea too complicated once I really thought about it. I wasn't able to use the list box and went to something else.



Thanks for your help!



John

Avatar

Former Community Member
I feel like you may be making this more complex than it needs to be. Instead of writing all of those IF statements, why can't you just say "if the specific selection is selected" make the subform visible. You should be able to use indexes to programatically refer to the item in the list box you need. As long as you aren't dynamically populating the list box you should be fine. Also, Paul is right, newText won't work there.