Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Change color of button master page

Avatar

Former Community Member
Hello,



I've been working on this for 2 weeks and can't figure it out. Any help would be appreciated.



I have a button (btn1) on my master page (mPage). I want to change the color of this button to red when the user chooses one radio button (radiobtn) on page 2 of a 3 page form. After that, the master page btn1 will be red for all the user pages (pages 1 through 3). Any idea how to do this?



Any ideas?



Thanks,

Ralph
4 Replies

Avatar

Former Community Member
Depends on which language you choose. Each button has a unque name based on the occurance number of its parent subform (assuming the parent subform in the Master page is called Page1). You can see this by adding the javascript code this.somExpression to the master page button. You will see that the expression is generally of the format form1.pageSet.Page1[occuranceNumber].ButtonName. You will have to address each one individually to change it. The parameter you want is: buttonname.border,fill.color.value = "R value, G value, B value"



This is a case where FormCalc has an advantage because you can use the * in the occurance number to reference all occurances of the Button.



If you choose to use Javascript you will have to determine how many occurances of pageSet.Page1 there are then loop through each one using a for loop to get each separate ocurance and setting it one by one. Note that in javascript the [] are interprestted as an array index so you will have to use the cfa.resolveNode syntax like this (assuming i is the counter in your for loop):



xfa.resolveNode("form1.pageSet.Page1[" + i "]").ButtonName.border.fill.color.value = "255,0,0";

Avatar

Former Community Member
Paul,



Thank you for your help. Your suggestion definitely works but I can't figure out how to solve 1 glitch. I can change the button color on any master page as you suggested. However, if any subform on that page recalulates, the master page button goes back to the original color. Could you please let me know what I am doing wrong?



Thanks,

Ralph

Avatar

Former Community Member
That is because the page is layed out again each time. The button is being reset to its original state. You can put your test on the calculate event. That event will get fired each time the page is layed out.

Avatar

Former Community Member
Thanks much. I knew it must be straightforward. Paul, you are great. We appreciate your help on this forum.



Ralph