Expand my Community achievements bar.

Assigning value to selection for drop down list

Avatar

Former Community Member

Have a drop down list with yes or no choices.   Yes will let you add instances of an item.  When the user deletes all the items, I want to set the choice to No.

Haven't been able to figure out how to change the answer in Javascript.

Any help would be appreciated.

Thanks,

Patrick

12 Replies

Avatar

Level 10

You need to put the code in the delete button click event. After deleting the intance, check for the InstanceManager count and if it is "1" or "0" based on your requirement, set the rawValue of the DropDown to "No"..

Subform.instanceManager.removeInstance(intIndex);

var intTotalInstances = Subform.instanceManager.count;

//Check the total instances after each delete of the Instance

if(intTotalInstances == 1){

     DropDown1.rawValue = "No";

}

Thanks

Srini

Avatar

Former Community Member

Tried it without success.

Am using this.parent...parent.drop_-box.rawValue = "No";

Avatar

Level 10

Seems to be you are not referencing to the control properly.

You can test your code by putting the same line of code in a messagebox.

xfa.host.messageBox("" + this.parent...parent.drop_-box.rawValue);

If you get the current value of the dropdown, then we have to check other reasons.

If you do not get the current value of the dropdown, then the problem is in how you are referencing the control.

If you still have issues after the above test, if you can, post your form and I can have a look at it.

Steps to upload the document

1) goto acrobat.com website
2) login with your Adobe login/password.
3) In Actions you will find Upload. Select your form and upload.
4) After uploading, select form name in All Files section and right click and select share.
5) Check the checkbox "Allow anyone with a link to view this document".
6) Copy the URL link and post it in the forum.

Thanks

Srini

Avatar

Former Community Member

Dear Srini,

Your answer is the one I expected to work.  You are on to something about acess to the correct node.

I tried a direct reference to the drop box form1....dropdownlist.rawValue and in Javascript it says it doesn't recognize "form1".  Not sure if I am up against an upper limit of file size or why it is acting up.  If I did this.parent.parent...dropdownlist.rawValue the reference is to a null node.

Thanks,

Patrick

Avatar

Level 10

If you can, post your form and I can have a look at it.

Steps to upload the document

1) goto acrobat.com website
2) login with your Adobe login/password.
3) In Actions you will find Upload. Select your form and upload.
4) After uploading, select form name in All Files section and right click and select share.
5) Check the checkbox "Allow anyone with a link to view this document".
6) Copy the URL link and post it in the forum.

Thanks

Srini

Avatar

Former Community Member

Logged in, but where do I find #3 Action?

Having issues looking to retrieve prevText as well.

Avatar

Level 10

You need to click on Files on the top and click on Upload in the left menu. (As shown in the picture).

Acrobat FileUpload1.JPG

After you upload the file, right click the file and choose share..

Acrobat File Share.JPG

Avatar

Level 10

I am looking at the document..It's a very big document. Can you please provide some write up on which page/ where the problem is?

Thanks

Srini

Avatar

Former Community Member

For this portion, skip the log in page.  Preview the document, go to the 7th page (has New Buildings? on the right) and select Yes.

When the number of new buildings goes to zero, I want the dropdown list to go to No or better yet "" (no answer).

Avatar

Level 10

The reference to the dropdown was changed like the following to fix the issue..

     xfa.form.form1.NewBuildings_SF.NewBuildings.rawValue =0;

I got the correct reference to the DropDown box by putting a messageBox in the change event of the Dropdown.

     xfa.host.messageBox("" + this.somExpression);

Since the DropDown is not part of the repeating NewBuildingList, you can directly reference the DropDown box in your code instead of traversing thru the parent.parent...  etc

     this.parent.parent.parent.parent.parent.NewBuildings.value = 0;

Thanks

Srini