These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Drop Down menu makes field readOnly

hattg
Registered: Jun 18 2009
Posts: 36

First, let me say thanks to everyone who has helped me with all my questions. You have great knowledge and I appreciate you sharing it with us all.

What I have is a field, that needs to be locked/disabled/read only if nothing in a Drop Down menu has been chosen. After something is chosen in the Drop Down menu, I need the field to be open to allow input.

The code I have come up with is doing the exact opposite. The field is open when the Drop Down menu has not been chosen, and locked when something has been. I have changed the open and readOnly to be opposite, but that doesn't fix it. Also have made the code check for not empty (!=), and that does not work either.

I am sure it has something to do with it being a Drop Down and the value of such. These two fields are in the same Subform, which is also a Dynamic table. Here is my code:

if (form1.P1.TestBlock.OrderSection.OrderItems.Assembly.rawValue == "")
{
xfa.resolveNode("form1.P1.TestBlock.OrderSection.OrderItems.Quantity").access = "open";
}
else
{
xfa.resolveNode("form1.P1.TestBlock.OrderSection.OrderItems.Quantity").access = "readOnly";
}

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If the "OrderItems" subform (or table line, whatever it is) is the repeating element, then I would think that you want each "Quantity" field to be controled by the "Assembly" field in the same line? If this is true then you need to use relative SOM paths in the code.

The correct place for the code is an event script in "Assembly" fields. Specifically, an event that occures after a selection has been made so that the field value is testable. Be sure to set the "Commit" property of the drop-down to "Select".

So a good place to put the code is in the "Validate" event because this event is called not only when a selection is made, but also when the field is changed from an outside source, like another script. If thats the case then the field value is acquired from "this.rawValue", where "this" is a pointer to the current field. Keep in mind though that "this.rawValue" returns the export value of the selected item, not the item text.
Use this code:
// Two test, one for no selection (i.e. a null value) and one test// for an empty entry where the export is set to "None"// Your setup may be differentif ( (this.rawValue == "") || (this.rawValue == "None") ){// No SelectionQuantity.access = "readOnly";}else{Quantity.access = "open";}

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script