Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments

Javascript in Fragment not working

Avatar

Level 2


I just don't see why the following isn't working. I know it's a pretty simple javascript to

display something when it's value is chosen. I'm a novice and just trying to understand the

logic here...

I have several drop-down lists - each one saved as a Fragment since some will be used on other

forms. On the PDF form, I have the first fragment set as "visible" and the other fragments set

as "invisible". The javascript is saved within the fragment itself.

In the first (visible) drop-down on the form, when the 1st choice is picked nothing appears.

(This drop-down has values of 1, 2, 3 and 4). When the second choice is picked the 1st choice

appears (instead of the 2nd choice). Neither the 3rd or 4th fragments appear when they are

picked as well.

What am I missing here? (Thanks for anyone's help)

- ed


DataManageForm.DataManageSubform.DropDownAdmin::exit - (JavaScript, client)

if(this.selectedIndex == 1)
{
PermissionsSubform.presence = "visible";
this.resolveNode("PermissionsSubform").addInstance(1);
}
else
{
PermissionsSubform.presence = "hidden";
this.resolveNode("PermissionsSubform").addInstance(0);
}
if(this.selectedIndex == 2)
{
PersonalSubform.presence = "visible";
this.resolveNode("PersonalSubform").addInstance(1);
}
else
{
PersonalSubform.presence = "hidden";
this.resolveNode("PersonalSubform").addInstance(0);
}
if(this.selectedIndex == 3)
{
AnthropoSubform.presence = "visible";
this.resolveNode("AnthropoSubform").addInstance(1);
}
else
{
AnthropoSubform.presence = "hidden";
this.resolveNode("AnthropoSubform").addInstance(0);
}
if(this.selectedIndex == 4)
{
FitnessTestSubform.presence = "visible";
this.resolveNode("FitnessTestSubform").addInstance(1);
}
else
{
FitnessTestSubform.presence = "hidden";
this.resolveNode("FitnessTestSubform").addInstance(0);
}
this.rawValue;

0 Replies

Avatar

Level 4

So in each case are you trying to set the drop-down to visible and add 1 instance?

Avatar

Level 2

Yes... and each fragment thereafter is the same... The next drop-down with selections that make the following (next) drop-down appear - the particular fragment to appear depending on the choice just made.

Thank you, Dallas...

- ed

Avatar

Level 4

Ed, would you be able to embed the fragments in your from and attach it so that I can get a clear understanding of what you have in mind. Thanks.

Avatar

Level 2

I hope the attached will help.

Thank you for taking time for this, Dallas.

- ed

Avatar

Level 4

My pleasure. Please can you embed all the fragments in the form and re-attach. Im getting broken links cos i dont have the fragments.

Avatar

Level 2

Sorry about that...

The first fragment is the only one currently with javascript. Hopefully, when I see what's wrong with that one I can proceed to set the other ones up correctly. (More drop-downs follow these... with the final choice an http to a separate dynamic form populated by a SQL query.)

Here 'tis...

- ed

Avatar

Level 4

Hey Ed, I changed the script a little. I think a switch statement handles that functionality nicely. But thats my personal preference. The selectedIndex property is 0-based. This means the first item in the list has a selectedIndex of 0; the second item in the select list has a selectedIndex of 1, and so on. I also changed the parent subform to be flowed so that the newly selected box will always appear neatly underneath the selection box without any big spaces between the boxes. If this is not what you wanted you can just return it to a positioned subform. Anyway, I think this is what you were wanting to do. Let me know if I missed something.

Avatar

Level 2


Gosh! What a simple clean code! That's it, Dallas...

It's such a nice thing here when a stranger helps someone like this.

Thank you so much, Dallas! Problem solved!

- ed