Expand my Community achievements bar.

SOLVED

Help with scripting...

Avatar

Level 1

Hello,

I am trying to complete a script where the fill color of a numeric field changes when the user selects a particular option from a drop down list. My code in initialize works for the default selection in the list, but I can't seem to get the form to change the fill color when the drop down list is changed. This is my code under change event for the drop down object:

if

(topmostSubform.Page1.DropDownList1.rawValue == "OPTION A")

{

topmostSubform.Page1.NumericField1.fillColor

= "50, 205, 50";

}

if

(this.rawValue == "OPTION B")

{

topmostSubform.Page1.NumericField1.fillColor

= "255, 0, 0";

}

if

(topmostSubform.Page1.DropDownList1.rawValue == "OPTION C")

{

topmostSubform.Page1.NumericField1.fillColor

= "255, 255, 0";

}

Appreciate any help!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Try this in the exit event of the dropdown:

if (this.rawValue == "OPTION A")

{

     NumericField1.ui.oneOfChild.border.fill.color.value = "50,205,50";

}

else if (this.rawValue == "OPTION B")

{

     NumericField1.ui.oneOfChild.border.fill.color.value = "255,0,0";

}

else

{

     NumericField1.ui.oneOfChild.border.fill.color.value = "255,255,0";

}

The form will need to be saved as a Dynamic XML Form and you will need to give the NumericField an initial while background colour.

Hope that helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

Try this in the exit event of the dropdown:

if (this.rawValue == "OPTION A")

{

     NumericField1.ui.oneOfChild.border.fill.color.value = "50,205,50";

}

else if (this.rawValue == "OPTION B")

{

     NumericField1.ui.oneOfChild.border.fill.color.value = "255,0,0";

}

else

{

     NumericField1.ui.oneOfChild.border.fill.color.value = "255,255,0";

}

The form will need to be saved as a Dynamic XML Form and you will need to give the NumericField an initial while background colour.

Hope that helps,

Niall

Avatar

Level 10

Hi,

I have updated two of our examples, which now use the oneOfChild scripting property. Previously I had been creating SOM Expressions for the objects and resolving the node, until put straight on the issue by John Brinkman.

Here are the links to the updated examples:

Page 2 of this example: http://assure.ly/ewrLMo

Using a function in a script object: http://assure.ly/h8ZLr5.

Niall