Expand my Community achievements bar.

Get the last focus

Avatar

Former Community Member
Hi!



Is there a possiblity to check within a click event of a button the field that got the focus before clicking on the button?



Thank you in advance!
3 Replies

Avatar

Level 7
You will have to create a variable with a document level scope and save the field name into this variable as each field losses focus.

Avatar

Former Community Member
how do I create a variable with a doc-level scope? That would be great :)

Avatar

Level 7
From LiveCycle Scripting Basics, available form the documentation pages.



To define a text variable

1. Select File > Form Properties.

2. In the Variables tab, click New (Insert) .

3. In the Variables list, type a unique name for the variable and press Enter. Variable names are

case-sensitive and should not contain spaces.

4. Click once in the box to the right and type the text you want to associate with the variable.



The variable appears in the Hierarchy palette at the form level.



Using variables in calculations and scripts

After you have created form variables, you only need to reference the variable name in your calculations and scripts in order to obtain the value of the variable.



Caution: When naming variables, you should avoid using names that are identical to the names of any XML Form Object Model properties, methods, or object names. For information about XML Form Object Model properties, methods, and objects, see the Adobe XML Form Object Model Reference at www.adobe.com/devnet/livecycle/designing_forms.html.



For example, create the following form variable definitions.



New form variable

Variable name Value

firstName Tony

lastName Blue

age 32



In FormCalc, you can access the variable values in the same manner that you access field and object values. In this example, the values are assigned to three separate fields:



TextField1 = firstName

TextField2 = lastName

NumericField1 = age



You can also use variables in FormCalc functions in the same way, as shown in this example:



Concat( "Dear ", firstName, lastName )

In JavaScript, you reference variable values by using the .value property instead of the .rawValue property that is used for field and object values, as shown in this example:



TextField1.rawValue = firstName.value;



See the following links for more documentation about LiveCycle Designer:



http://kb.adobe.com/selfservice/viewContent.do?externalId=333249&sliceId=1



http://www.adobe.com/devnet/livecycle/designing_forms.html