Highlighted

JavaScript: if user checks box, change fill color of text field

Avatar

30-07-2008

Hi



Is there a way, using JavaScript in LiveCycle ES (8.2), in a dynamic form (saved as XML .pdf) for the script to determine if a text field is currently displaying in runtime (initializes as "invisible" and is made visible if the user checks certain check boxes).

There are 7 check boxes any or all of which, if checked, will display the text field (and can be checked and unchecked), so it seems easier to script if the text field is showing rather than any/all of the check boxes. This would solve part 1 of a 2 part challenge.



The second scripting challenge would be to add a second condition: what is the current selection chosen in a drop down list box: I am already using:var sNewValue = this.boundItem(xfa.event.newText)

AND depending on which text selection is currently chosen, PLUS if the text field (see above) is currently showing, set/change the fill color of a cell in a table to a RGB value.



New to (JS) scripting LiveCycle, I have not been able to set up these complex conditional statements: while TextField1 is showing, and if the current selection (in the drop down list box) = "xyz", then: Table1.Row1.Cell2.fillColor = "0,128,0", else if, while TextField1 is showing and the current selection is "abc", set the same fill color (or a different color) for a different cell.



I tried the following (click event in a test button) without success:



var sNewValue = DropDownList1.boundItem(xfa.event.newText)

if (sNewValue == "prostate cancer, early onset: < 60")

&& TextField3.presence == "visible"

{

Table1.Row1.Cell2.fillColor = "0,128,0";

}



Nothing happened when the test button was clicked.



Any help would be appreciated. (While I would prefer not to post the draft form online, I would be happy to send it via email if someone offering suggestions would like to have a look and provides their email address.)



Kind Regards,



Stephen

Replies

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

30-07-2008

Post it to livecycle8@gmail.com as well as a description of the issue and I will have a look.
Highlighted

Avatar

30-07-2008

Thanks, Paul.



Sent file as email attachment to livecycle8@gmail.com



Stephen