Change Text Color
In this example you will set up a document to enable the shopper to change the color of the text throughout the document by simply choosing an item in a drop-down list.
NOTE: You should not create actions that change process colors to spot colors or vice versa because the changes are not taken into account in your pricing.
Summary
Action type: On Change (In the Actions tab, edit On Change.)
Variable type: List with 3 items: my_color_1, my_color_2, my_color_3
Document with the following colors:
My_Default_Color: Apply this color to the text that you want to change with the action
My_Blue, My_ Green, My_Red: colors applied to the text formatted with My_Default_Color, depending on the selected list item
Action code:
1 if variable Change text Color selectedItemName is string my_color_1
2 set color My_Default_Color applyFromColor = color My_Red id
3 else if variable Change text color selectedItemName is string my_color_2
4 set color My_Default_Color applyFromColor = color My_Green id
5 else if variable Change text color selectedItemName is string my_color_3
6 set color My_Default_Color applyFromColor = color My_Blue id
7 end if
On Change Action to change text color 
NOTE: This procedure is similar to the one for creating an action to switch layers in a document. Refer to “On Change Action to show/hide layers” for more details on creating the action, but replace the action code as specified below.
1 Edit your document in the Online Editor and check in the Text tab that the text frame contains the colors that you want to use in your variable action:
My_Default_Color
My_Blue
My_ Green
My_Red
In Edit Text mode, select the text and open the Character Settings panel.
It is recommended to create your colors in the original InDesign document. However, you can also create these colors at this stage, in the Online Editor, by renaming and overwriting colors in the list which are not being used in the document: select a color in the drop-down list, and click the color patch to open the Color editor.
2 Assign My_Default_Color to the text you want to modify with the action.
NOTE: Do not assign dedicated InDesign colors such as [Black] and [White] to the text you want to modify. These colors cannot be modified by the variable action and will generate errors when you try to save your document.
3 Save the document and go to the Forms tab, to create the variable with actions.
4 In the Forms tab, click the Add button and then the pencil icon to open the New Variable dialog.
5 In the General tab of the New Variable dialog, complete as follows:
Name: Change text color
Display Name: Change text color
Type: Choose List from the drop-down.
6 In the Type Specific tab, click the Add button and create 3 list items:
my_color_1
my_color_2
my_color_3
7 Click the Actions tab and then the On Change Edit button to start the Action editor.
The Action editor is opened without any code lines.
8 In the Code tab, add the following lines of code.
1 if variable Change text color selectedItemName is string my_color_1
2 set color My_Default_Color applyFromColor = color My_Red id
3 else if variable Change text color selectedItemName is string my_color_2
4 set color My_Default_Color applyFromColor = color My_Green id
5 else if variable Change text color selectedItemName is string my_color_3
6 set color My_Default_Color applyFromColor = color My_Blue id
7 end if
NOTE: The values after string must be typed in the fields.
NOTE: Instead of switching color swatches, it’s also possible to specify color values. In this case the code is:
set color My_Default_Color colorValue = colorvalue cmyk 20 100 90 0
9 When you have created all the lines of code, click Apply to save your changes.
10 Click Close to finish your variable settings and save the document.
11 In the Step 3: Initialize Form Variables panel, you can check that your variable is working as expected and emulate the shopper experience.
The Change text color variable has three items in the drop-down list. The shopper can select a text color for the text frame by choosing one of the items in the list.
doc. version 6.0.4