Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Changing the background colour of a tabe cell, according to the selection in a drop down list

Avatar

Level 2

I have a drop-down list wrapped in a subform in a table cell. Users can pick Green, yellow or red and I want the background colour to change according to their selection.

Can you tell me why this script is not working? I am sure some of you folks can see it in a second.


if (this.ListItem=="green") {

Subform1.DropDownList1.fillColor = "000,128,000"; BackgroundFill="solid";

}                  

if (this. ListItem=="yellow") {

Subform1.DropDownList1.fillColor = "255,128,000";

}

if (this.ListItem=="red") {           

Subform1.DropDownList1.fillColor = "255,000,000";     

}


Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I think you should be able to use the following code in the change event of the dropdownlist.

form1.#subform[0].Table1.Row2.DropDownList1::change - (JavaScript, client)

if (xfa.event.change=="green") {

  this.fillColor = "000,128,000";

}                 

if (xfa.event.change=="yellow") {

  this.fillColor = "255,128,000";

}

if (xfa.event.change=="red") {          

  this.fillColor = "255,000,000";    

}

Regards

Bruce

View solution in original post

12 Replies

Avatar

Correct answer by
Level 10

Hi,

I think you should be able to use the following code in the change event of the dropdownlist.

form1.#subform[0].Table1.Row2.DropDownList1::change - (JavaScript, client)

if (xfa.event.change=="green") {

  this.fillColor = "000,128,000";

}                 

if (xfa.event.change=="yellow") {

  this.fillColor = "255,128,000";

}

if (xfa.event.change=="red") {          

  this.fillColor = "255,000,000";    

}

Regards

Bruce

Avatar

Level 2

Thank you for your patience Bruce!

I applied your suggestion but unfortunately, it does not change the colour. I put the form in question Project Status Report on the Google drive:

https://drive.google.com/drive/folders/0B2VrTxepsjnsUWRGeG9SblZPSTA

The other two forms in that folder are from an earlier inquiry. The Tabletest works fine but the same approach in the Bulk IT...does not propagate rows to the next page and for the life of me, I cannot figure out why.

THX again,

Lisa

Avatar

Level 10

Hi Lisa,

I'm getting a "The folder that you were viewing no longer exists or you no longer have permission to access it. You have been moved to My Drive." message when trying to view your folder.  Can you check the sharing permissions.

Thanks

Bruce

Avatar

Level 2

please check forums_noreply@adobe.com. I needed an e-mail address to share the folder and that's what I have. If you have an additional address, I'd gladly add it.

https://drive.google.com/drive/folders/0B2VrTxepsjnsUWRGeG9SblZPSTA

Thanks!

Avatar

Level 10

Hi Lisa,

You should be able to set the file to "Anyone with the link" and then post the link that Google generates.  Have I look at this page Change your sharing settings - Drive Help

Regards

Bruce

Avatar

Former Community Member

Hi,

add this code to the enter event of the dropdown.

this.resolveNode("$").ui.oneOfChild.border.fill.color.value = "255, 255, 255";

add this code to the change event of the dropdown.

 

if ($.boundItem(xfa.event.newText) == "Green") {

  this.resolveNode("$").ui.oneOfChild.border.fill.color.value = "0, 128, 0";

 

if ($.boundItem(xfa.event.newText) == "Red") {

  this.resolveNode("$").ui.oneOfChild.border.fill.color.value = "255, 0, 0";

  

if ($.boundItem(xfa.event.newText) == "Yellow") {

  this.resolveNode("$").ui.oneOfChild.border.fill.color.value = "255, 204, 0";

Avatar

Level 2

Hi,

Thank you for your suggestion. Unfortunately, the scripts are not working as hoped.

I put the form "Project Status Report_2" in the shared Google folder here: PDF forms.The drop-down list in question is in section "3. Deliverable Status".

I added your scripts on enter* and change* to the first row, second column.

Rows 2-4 have the script that changes the colour but on exit, every cell defaults back to green. Do you know how I can fix that?

Thanks again!

Lisa

Avatar

Level 10

Hi Lisa,

Have a look at this sample.

https://sites.google.com/site/livecycledesignercookbooks/home/Project%20Status%20Report_2.pdf?attred...

You had a syntax error in the script, the closing brace was missing from the if statement.  In the script editor there's a book with green tick overlay icon that will check your scripts for syntax errors (you might have to show the Warnings window ...  select Windows ... Report (it should appear at the bottom of the screen)).  Also in Acrobat make sure that ... "When exception is thrown:" is set to break under Edit ... Preferences ... JavaScript.

The script in row 1 updates the "ui" portion of the drop down list, the other rows update the whole cell, you had a mix and I'm not sure which you wanted.

Regards

Bruce

Avatar

Level 2

Hi Bruce,

The script in row 1 was sent to me earlier in this discussion by "sp215". I just cut and pasted it, not checking the syntax...not noticing the missing }s.

I want to use my script (as in rows 2, 3, 4) and fill the whole cell, not only the border. It works fine until I exit, then every cell defaults back to green.

What script do I need on exit event to make it stick?

Thank you!

Lisa

Avatar

Level 10

Hi Lisa,

There seems to be some code (I guess from an earlier attempt) in the exit event of the Subform1 that contains the drop down.  This code is no longer required and should be removed.  It is this code that changes the brackground back to green (because the if statement only has one "=" sign).

Bruce

Avatar

Level 2

Hi Bruce,

I checked all the cells with scripts and there is nothing on an exit event.The problem was that the subforms were all called Subform1 instead of 1, 2, 3, 4.

So, this code works fine now:

if (xfa.event.change=="green") {

  this.fillColor = "000,128,000";

}                 

if (xfa.event.change=="yellow") {

  this.fillColor = "255,128,000";

}

if (xfa.event.change=="red") {          

  this.fillColor = "255,000,000";    

}

Many thanks...all good!!!

Lisa