Expand my Community achievements bar.

SOLVED

Can a Check Box Control a Drop-Down List?

Avatar

Level 2

In my form, I have a drop-down list & a check box next to the list.  The check box is entitled "N/A", indicating the available information in the drop-down list is not applicable. I would like the N/A check box to disable or clear the drop-down list, so it cannot be calculated later.  Could a Radio Button be programmed to deactivate the drop-down list?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I think the problem is that you have lots of instances of objects with the same name. This is indicated by the [0] after the object's name. This makes it more difficult (not impossible, but more awkward).

Basically, first try to rename the objects so that each has a unique name. Then reference these in the script.

If you keep with multiple objects with the same name, then you would need to explicitly tell Acrobat which object you want the script to deal with. This is called resolving the node and would look something like this (eg depends on your form's structure):

xfa.resolveNode("form1.page1.DropDownList1[0]")

This would apply to all objects in your script that have the same name as other objects in the form.

Try naming objects as you go, so that you don't have to change script later on.

Good luck,

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi,

Yes, you can do that with a little bit of script in either the mouseUp or exit event of the checkbox:

if (this.rawValue == 1) // 1 = on

{

     dropdown1.rawValue = null;

     dropdown1.access = "readOnly";

}

else

{

     dropdown1.access = "open";

}

Alternatively you could hide the dropdown:

if (this.rawValue == 1) // 1 = on

{

     dropdown1.rawValue = null;

     dropdown1.presence = "hidden";

}

else

{

     dropdown1.presence = "visible";

}

Hope that helps,

Niall

Avatar

Level 2

As I'm a bit new to scripting, could you walk me through a few things?

First, let's just take my first drop-down list & check box.  I will probably be able to duplicate the process, once I understand what I'm doing.

The drop-down box is labeled "DropDownList1[0]". the checkbox is "CheckBox9[0]"

I understand how to select The functions, and I tried to copy & paste your example into the scripting box.  I don't get an error, but the function did not work.  I'm sure it had something to do with the way I plugged in your string.

Please walk me through the process, so I can get it to work.

Thank you for your help!

Avatar

Correct answer by
Level 10

Hi,

I think the problem is that you have lots of instances of objects with the same name. This is indicated by the [0] after the object's name. This makes it more difficult (not impossible, but more awkward).

Basically, first try to rename the objects so that each has a unique name. Then reference these in the script.

If you keep with multiple objects with the same name, then you would need to explicitly tell Acrobat which object you want the script to deal with. This is called resolving the node and would look something like this (eg depends on your form's structure):

xfa.resolveNode("form1.page1.DropDownList1[0]")

This would apply to all objects in your script that have the same name as other objects in the form.

Try naming objects as you go, so that you don't have to change script later on.

Good luck,

Niall

Avatar

Level 2

Thank you, Niall!

That worked.

Good advise, by the way.  When each field has it's own name, it makes writing the script far easier.

Thank you, again!

Robert