Highlighted

Multiple Select List Box Problem

Avatar

Avatar

johnqdaily

Avatar

johnqdaily

johnqdaily

13-08-2008

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

Replies

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

13-08-2008

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.
Highlighted

Avatar

Avatar

johnqdaily

Avatar

johnqdaily

johnqdaily

13-08-2008

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
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

13-08-2008

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?
Highlighted

Avatar

Avatar

johnqdaily

Avatar

johnqdaily

johnqdaily

13-08-2008

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
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

13-08-2008

I agree ...it was too compicated.
Highlighted

Avatar

Avatar

Ryan_Lunka

Avatar

Ryan_Lunka

Ryan_Lunka

18-08-2008

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.