Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Show/hide field based on drop down selection

Avatar

Level 1

I'm having a hard time with some scripting for a form where  would like to show/hide a field based on a selection in another drop down field.  I have two choices in the drop down and I have bound numbers to the selections.  I created a script that I thought would work based on information I found in the forums, but I had no luck.  Here is the script I wrote for the drop down field.

form1.#subform[0].PriChoice::change - (JavaScript, client)

if

(PriChoice.rawValue == 0)

{PhonePri.presence

"visible"

}

else

{PhonePri.presence

= "hidden"

}

I'm not sure wht I have wrong, but the fieled shows visible regardless of teh drop down selection.  I wold certainly appreciate any help abyone can offer.  I am very new to livecycle and writing script.

-Mark

4 Replies

Avatar

Level 1

This is the actual script, but somehow the line breaks show differently in my script editor...

form1.#subform[0].PriChoice::change - (JavaScript, client)

if

(PriChoice.rawValue == 0)

{PhonePri.presence

= "visible"

}

else

{PhonePri.presence

= "hidden"

}

Avatar

Former Community Member

1st thing is that the script is on the chane event o fthe dropdown.....so the value that the user selects doe snot get committed until the user leaves the field so the rawValue will NOT contain what you think it shoudl. If you move th ecode to the exit event then it shodul work. If you want to continue to use the change event you shodul be using  xfa.event.newText instead.

2nd make sure that the form is saved as a dynamic form other wise presence changes willl be ignored.

Paul

Avatar

Level 6

I can take a look at your form if you'd like:

killing time and looking for something to do.

pbeef2000@yahoo.com

Avatar

Level 5

Hi,

Because you are using the change event and a dropdown list I would recommend that you use

"event.newText" instead of "PriChoice.rawValue"

This will make sure you get the currently selected item from the drop down list.

The other point would be does the dropdown list have a item of value 0, as it may be none of the values match 0

If you look at this panel in LC Designer you can see what values are assigned to the dropdown list.

DropDownItems.jpg

Can you post your form somewhere ( acrobat.com, etc....) so that we can help you?

Hope this helps

Malcolm