5 Replies Latest reply on May 14, 2012 9:03 PM by blackops_programmer

    Unable to change button bg color in Masterpage

    blackops_programmer Level 1

      I have 2 buttons (ButtonShow and ButtonHide) that I have inserted in my masterpage 1. These buttons control the object elements in design page and chooses either to show or hide the fields depending on the selection. These are the scripts I have for these buttons:

       

      ButtonShow script:

      pageSubform.HeaderWrap.DropDownList1.presence = "visible";
      pageSubform.HeaderWrap.TextField1.presence = "visible";
      this.border.fill.color.value = "255,140,26";
      ButtonHide.border.fill.color.value = "212,208,200";
      

       

      ButtonHide script:

      pageSubform.HeaderWrap.DropDownList1.presence = "invisible";
      pageSubform.HeaderWrap.TextField1.presence = "invisible";
      this.border.fill.color.value = "255,140,26";
      ButtonShow.border.fill.color.value = "212,208,200";
      

       

      My Problem: Although the above script works in hiding or showing the objects, the background color of the ButtonHide does not change for some reason. However, these buttons works perfectly if I move these buttons from Masterpage to the design page. When placed in the design page, it hides the objects as well as changes the bg color of the buttons. But when I place these button inside the masterpage1, it does not change the bg colors for some reason when ."ButtonHide" is clicked. I dont understand why that is...I was also reading around in the forums and I read somewhere by Niall O'Donovan that "If your script is in an object on the Master Page then relative references should work. However if your script is in an object on the Design Pages and you are referencing objects on the Master Page in the script, then you will need to resolve the node." So I tried the code with the resolveNode method like this and it still does the same, meaning the bg color doesnt change although it hides the fields:

       

      Alternative ButtonHide script:

      this.border.fill.color.value = "255,140,26";
      ButtonShow.border.fill.color.value = "212,208,200";
      xfa.resolveNode("xfa.form.form1.pageSubform.HeaderWrap.DropDownList1").presence = "invisible";
      xfa.resolveNode("xfa.form.form1.pageSubform.HeaderWrap.TextField1").presence = "invisible";
      

       

      However, I noticed that the bg color changes if I remove these 2 lines from the code:

      xfa.resolveNode("xfa.form.form1.pageSubform.HeaderWrap.DropDownList1").presence = "invisible";
      xfa.resolveNode("xfa.form.form1.pageSubform.HeaderWrap.TextField1").presence = "invisible";
      

       

      I dont understand this strange behaviour and why its happening...hopefully someone can shed some lights....thanks for reading my post..