Total Pageviews

Monday, 19 August 2013

Livecycle Designer: Changing the background colors of fields, fillable areas, and subforms

Dynamically setting image field href

I'm trying to dynamically set an image field on my LiveCycle PDF form. On my form onReady function I have some Javascript code that is executing. For some reason, if I explicity set my image field to a string value, everything works. However, if I try to dynamically set it using a value from a text input, it doesn't work.

Any ideas? I've used app.alert to make sure that the value in the textfield is correct.

//Try to set image field to a string value. [WORKS]
swatch1.image.value.image.href = "http://localhost/qs/images/waterswatch.png";
 
//Alert Value of text field (Result: http://localhost/qs/images/waterswatch.png )
app.alert(swatch1.imgPath.rawValue)
 
 //Try to set image field dynamically. [DOESNT WORK]
 
 
swatch1.image.value.image.href = swatch1.imgPath.rawValue;
 
 
 


Changing the background colors of fields, fillable areas, and subforms

This example demonstrates how to change the background color of subforms, fields, and fillable areas on a form in response to form filler interaction at run time.
In this example, clicking a button changes the background color of an associated object.
Note: To manipulate the background color of objects at run time, you must save your form as an Acrobat Dynamic XML Form file.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center at www.adobe.com/devnet/livecycle.
Scripting the subform and text field background colors
You set the subform and the text field background colors by using the fillColor method. For example, the following line is the script for the subform:
    Subform1.fillColor = "17,136,255";

The following lines make up the script for the background color of the text fields:
    Subform1.Name.fillColor = "102,179,255";
    Subform1.Address.fillColor = "102,179,255";
    Subform1.City.fillColor = "102,179,255";
    Subform1.State.fillColor = "102,179,255";
    Subform1.ZipCode.fillColor = "102,179,255";
    Subform1.Country.fillColor = "102,179,255";

Scripting the fillable area background color
When setting the background color or the fillable area for each text field, your scripts must access properties that require a reference syntax expression that includes the number sign (#). Because JavaScript does not interpret the number sign (#) properly in reference syntax expressions, the script uses the resolveNode method to resolve the expression.
    xfa.resolveNode("Subform1.Name.ui.#textEdit.border.fill.color").value = "153,204,255";
    xfa.resolveNode("Subform1.Address.ui.#textEdit.border.fill.color").value = "153,204,255";
    xfa.resolveNode("Subform1.City.ui.#textEdit.border.fill.color").value = "153,204,255";
    xfa.resolveNode("Subform1.State.ui.#textEdit.border.fill.color").value = "153,204,255";
    xfa.resolveNode("Subform1.ZipCode.ui.#textEdit.border.fill.color").value = "153,204,255";
    xfa.resolveNode("Subform1.Country.ui.#textEdit.border.fill.color").value = "153,204,255";

No comments:

Post a Comment