Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Programming to show sub-form upon click of radio button?

Avatar

Former Community Member

I am currently working in LiveCycle Designer ES trying to create a form in which you click a radio button and one of the hidden subforms will become visible.  I know how to make the subform hidden, but don't know how to link the radio button for the subform to appear when a certain option is selected.  I am not terribly skilled in programming but can do my best to understand it if that's what it takes to make this happen.  I understand some concepts, but just don't know alot of the commands.  Suggestions?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You don't have to add script in the XML Source tab - it fact you should avoid going in there for most tasks.

There is a script editor, which will appear along the top of LC Designer. If it is not visible, you can open it from the Window menu or pressing F5.

Parallels Desktop1.png

So I would delete the script in the XML source (or delete the object and start again).

Along the top of the script editor you can select an event to script against, check the syntax and choose a language.

If you open the form, you will be able to explore the script in the radio buttons.

Your script looks OK. there should be a ';' at the end of the presence lines in Javascript.

I suspect that the form is saved as STATIC. If this is the case the script will not work. This is because showing and hiding objects is a dynamic feature and your form would need to be saved as DYNAMIC.

Good luck,

Niall

View solution in original post

5 Replies

Avatar

Former Community Member

The radiobuttons are usually in a RadioButtonList object (you will see this in the hierarchy). Click on that object on then in the script editor choose the change event. Now you can test to see what the selection was ..something like this:

if (this.rawValue == 1){

     turn on subform

} else {

     turn off subform

}

Hope that helps

Paul

Avatar

Level 10

Hi,

Here is a sample of radio buttons showing and hiding a subform: https://acrobat.com/#d=MnqBQrsWVc5gKwQFC9TyZA

The script is given in the form, explaining the process.

Hope that helps,

Niall

Avatar

Former Community Member

Thank you, that helps a bit...I think at least...

This is the script I included, in roughly the same spot as it was on the document that you included:

<event activity="click" name="event__click">

<

script contentType="application/x-javascript">

if (this.rawValue == 3)

{

EmployeeIndependentContractor.presence = "visible"

}

else

{

EmployeeIndependentContractor.presence = "hidden"

}

</

script>

</

event>

In this form, "EmployeeIndependentContractor" is a subform.  This didn't work however.  Is there something stupid that I'm overlooking?

Avatar

Correct answer by
Level 10

Hi,

You don't have to add script in the XML Source tab - it fact you should avoid going in there for most tasks.

There is a script editor, which will appear along the top of LC Designer. If it is not visible, you can open it from the Window menu or pressing F5.

Parallels Desktop1.png

So I would delete the script in the XML source (or delete the object and start again).

Along the top of the script editor you can select an event to script against, check the syntax and choose a language.

If you open the form, you will be able to explore the script in the radio buttons.

Your script looks OK. there should be a ';' at the end of the presence lines in Javascript.

I suspect that the form is saved as STATIC. If this is the case the script will not work. This is because showing and hiding objects is a dynamic feature and your form would need to be saved as DYNAMIC.

Good luck,

Niall

Avatar

Former Community Member

THANK YOU SO MUCH!  I got it and my boss is in love with me right now!