Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

fields visible when checkbox checked

Avatar

Level 3

Hello All,

I've found a lot of people asking similar questions but I'm not finding what works for me.  On my form, I have a checkbox and underneath the checkbox are numerical fields (with global settings which populate from other places) - a (rough) screen capture is shown below.  I only want the numerical fields to show if the checkbox (example:  Concentration:  Literary Studies checklist) is checked. 

            Do I make all the numerical fields a subform or indicate them all separately in the javascript? 

            What event do I use for my javascript?

Other things I've seen mentioned by other people are default value and presence.  I'm not sure why these would matter or if these issues are particular to their forms.

screencap.jpg

Any help would be great!

Thanks ~

10 Replies

Avatar

Former Community Member

Here is a script I use to display fields or subforms when a check box is selected.  I use it on the Change event (javaScript) and in the initialize event.  Adding it to the initialize event will maintain the presence of the field or subform when it is saved.

 

if

(this.rawValue==1)

    {fieldname.presence="visible"}

else

    {fieldname.presence="hidden"}

Avatar

Level 3

It works!  

OK -  One more question:  now the check box won't let me uncheck it.  There may be a senario where I'll need to do this.

Any thought on this?

Avatar

Former Community Member

The checkbox should let you uncheck it.  Do you have any security policies set on the form?  Or other "locks" such as digital signtures?

Avatar

Level 3

No security policies and we aren't progressive enough here to use digital signatures - Admin wants pen and ink.

Sorry to trouble . . . any other ideas?

Avatar

Former Community Member

You just have to change your field that won't unselect from a radio button to a checkbox. 

Avatar

Level 3

I’ve been through so many trials with this and I forgot to tell you - so sorry.  It was a check box initially but I changed it to a radio button to see if that would work. 

Neither checkbox nor radio button worked.

Such a little thing and so frustrating.   

Avatar

Former Community Member

I attached your form, I changed the field to a checkbox and it will allow

me to select and unselect it. Are you looking at the form in it's Preview

state in LiveCycle or from Acrobat Pro?

Check your form properties and change "preserve scripting changes to

form.... to Automatically in the Defaults tab and see if that helps.

Avatar

Level 3

I didn't see the form attached but no matter . . . I also changed the box back to a checkbox and I changed the form property you indicated, and I viewed in Acrobat Pro to no avail. 

It will will not uncheck for me. 

This seems like such a straightforward thing, I can't imagine why it won't work . . .