Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

DropDown value depends on another dropdown

Avatar

Level 5

I have placed a variable script from another file. Original file works well but my created file does not work.

https://acrobat.com/#d=Nla8o4s5FUP8Qp0cl-hAHg

I am unable where I have made a mistake. How can I solve it?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Give a propername to the Page1 subform in the heirarchy (for example Page1). Currently the default name is used (#Subform[0]).

Replace the references in the script object to the name given in the heirarchy.

That should resolve your issue.

Thanks

Srini

View solution in original post

6 Replies

Avatar

Correct answer by
Level 10

Give a propername to the Page1 subform in the heirarchy (for example Page1). Currently the default name is used (#Subform[0]).

Replace the references in the script object to the name given in the heirarchy.

That should resolve your issue.

Thanks

Srini

Avatar

Level 5

Another problem is seen.

After adding row and select Item, I see the value of size is gone from first row and I cannot select any size in new added row.

https://acrobat.com/#d=Nla8o4s5FUP8Qp0cl-hAHg

How can solve it?

Avatar

Former Community Member

Your issue is that in your function you are always referencing the 1st instance of the Size DDlist. Because you are doing this from a script object the context at which this script is running from changes so you have to explicitely say which one you want to change. If you were to leave the code in the DDList then ithe script would know the contxt that you are running in and you would not have to do this. I modified your form to show you how to do it with the scripting object. Note that I have to pass the row index that you are on when calling the function then use that in teh somExpression to set the size ddlist. You will have to do the same for the unit price later on.

I attached the file here ..if you want me to remove it just ask.

Hope that helps

Paul

Avatar

Level 5

Thanks Paul for your kind information.

I changed the scrript later. I have faced another problem to populate price into price field.

I have entered value in DropDown1 (Item);

In DropDown1 I have palaced following script:

if(this.rawValue =="Shirt")

PartList.clearItems();

DropDown2.addItem("Long Sleeve","0");

DropDown2.addItem("Short Sleeve","1");

...........

.........

Abobe script works well but following script does not work well:

In DropDown2 change event:

if(DropDown2.rawValue=="Long Sleeve")

TextField.rawValue = "30";

else if(DropDown2.rawValue=="Short Sleeve")

TextField.rawValue = "50";

I cannot realize where I have made mistake.

Avatar

Former Community Member

The rawValue property does not get set until you exit the field. Because you have coded it on the change event ....ythe vakue is not committed yet. So you have two choices ...you can move your code to the exit event (no change is required)...or if you want to stay on the change event you woudl test the xfa.event.newText instead of the this.rawValue . Note that you can only test this value once per event so assign it to a variable then test the variable in your code.

Make sense?

Paul