Expand my Community achievements bar.

SOLVED

Adding instance with dropdown values of previous instance

Avatar

Level 4

HI All!

Need some help with some javascript.   I have a form that has a radio button B that when you select it, shows a subform.  Inside the subform is a table that has a dropdown list.  The drop down list is populated based on a previous radio button A that was selected, and is a subset of possible values.

The user is able to click a button to create an additional instance of the subform.  Problem is the new instance is in the original version of the subform, and the drop down list does not have the selected subset of values.

How can I have the dropdown in the added instance only show the subset drop down values?

Let me know if you need more info.

Thank you!

Jodi

1 Accepted Solution

Avatar

Correct answer by
Level 10

You must make sure to access the right instance of Awardees..

Because you create new instances, you must access them by using the method resolveNode()

you can access the instance by using 0 based indexes, if you are within the initalize event of the dropdown list you can just use "this" instead of "Main.PreApproved.Awardees.Table1.Row1.AwardType"

When adding an instance on the Button click event :

Dropdownlist initialize event :

If you change value on the radio button (which changes subset values):

Hope this help!

View solution in original post

6 Replies

Avatar

Level 10

Hi there,

you can insert script within the initialize or enter event which verifies if the length of the list is equal to 0 and then it adds the value within the dropdownlist

If you need to change the subset values, always remember to clear the items first

Hope this will help

Avatar

Level 4

Which Initialize would I put it on?  For the button that creates the additional instance of the subform?

Currently on the click even of the button I have this

Awardees.instanceManager.addInstance(1).presence = "visible";

I have tried to add an if statement after that saying

if (Main.Campus.Urbana.rawValue == "1")

{Main.PreApproved.Awardees.Table1.Row1.AwardType.rawValue = "";

Main.PreApproved.Awardees.Table1.Row1.AwardType.clearItems();

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Excellence in Faculty Mentoring Award");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Excecutive Officer Distinguished Leadership Award");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Outstanding Faculty Leadership Award");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Campus Award for Excellence in Instruction");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Chancellor's Academic Professional Excellence Award (CAPE)");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Chancellor's Distinguished Staff Award");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Service Recognition Award")}

But that isn't working?

Avatar

Level 10

The initialize event of the dropdown list

Your goal is to keep each new instances of that dropdown list to keep the same list as all the others dropdown list, so when the dropdown list initialize itself,

you verify which subset values you want to add to the dropdown list by verifying urbana's value and then add it to the dropdown list

But what isnt working exactly? the code you just provided or you tried what I suggested?

Avatar

Level 4

Hi Magus!

The code that I entered above wasn't working on the click event of the button that adds the additional instance.

So what I did was on the drop down list I tried the following on both the initialize and the enter event, and it still doesn't work.

if (Main.Campus.Urbana.rawValue == "1")

Main.PreApproved.Awardees.Table1.Row1.AwardType.rawValue = "";

Main.PreApproved.Awardees.Table1.Row1.AwardType.clearItems();

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Excellence in Faculty Mentoring Award");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Excecutive Officer Distinguished Leadership Award");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Outstanding Faculty Leadership Award");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Campus Award for Excellence in Instruction");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Chancellor's Academic Professional Excellence Award (CAPE)");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Chancellor's Distinguished Staff Award");

Main.PreApproved.Awardees.Table1.Row1.AwardType.addItem("Service Recognition Award")}

Avatar

Correct answer by
Level 10

You must make sure to access the right instance of Awardees..

Because you create new instances, you must access them by using the method resolveNode()

you can access the instance by using 0 based indexes, if you are within the initalize event of the dropdown list you can just use "this" instead of "Main.PreApproved.Awardees.Table1.Row1.AwardType"

When adding an instance on the Button click event :

Dropdownlist initialize event :

If you change value on the radio button (which changes subset values):

Hope this help!

Avatar

Level 4

YES!  That did it!  I used the first example you gave me.  Thanks you so much Magus for the help!!!

Have a great weekend!

Jodi