3 Replies Latest reply on Mar 27, 2017 12:17 PM by gkaiseril

    Show Hide Many Fields based on Drop Down Selection

    MikeLiff82

      I have a drop down field with 65 or so choices. Based on the selection, I need specific buttons to be visible and other buttons to be hidden.  I have a working version of the cod but is is far too long to fit in the 1100 lines available.

      var layers = this.getOCGs();
      var v = event.value; 
      for (var i = 0; i < this.layers.length; i++) {if (layers[i].name == "AARP" && v == "AARP"||layers[i].name == "AETNA" && v == "AETNA"||layers[i].name == "AFFINITY EXCHANGE" && v == "AFFINITY EXCHANGE"||layers[i].name == "AFFINITY HEALTH" && v == "AFFINITY HEALTH"||layers[i].name == "AFFINITY MEDICARE" && v == "AFFINITY MEDICARE"||layers[i].name == "AGEWELL" && v == "AGEWELL"||layers[i].name == "ALICARE" && v == "ALICARE"||layers[i].name == "AMERICAN PROGRESSIVE" && v == "AMERICAN PROGRESSIVE"||layers[i].name == "AMERIHEALTH" && v == "AMERIHEALTH"||layers[i].name == "APWU" && v == "APWU"||layers[i].name == "AXA ASSISTANCE" && v == "AXA ASSISTANCE"||layers[i].name == "BCBS HEALTHPLUS" && v == "BCBS HEALTHPLUS"||layers[i].name == "BLUE CROSS" && v == "BLUE CROSS"||layers[i].name == "C R CONSULTING" && v == "C R CONSULTING"||layers[i].name == "CARECONNECT" && v == "CARECONNECT"||layers[i].name == "CHOICECARE NETWORK" && v == "CHOICECARE NETWORK"||layers[i].name == "CIGNA HEALTHCARE" && v == "CIGNA HEALTHCARE"||layers[i].name == "CONNECTICARE" && v == "CONNECTICARE"||layers[i].name == "CONSUMER HEALTH NET" && v == "CONSUMER HEALTH NET"||layers[i].name == "DEVON HEALTH SERVICE" && v == "DEVON HEALTH SERVICE"||layers[i].name == "DEWITT NURSING HOME" && v == "DEWITT NURSING HOME"||layers[i].name == "ELDERPLAN" && v == "ELDERPLAN"||layers[i].name == "EMBLEM HEALTH" && v == "EMBLEM HEALTH"||layers[i].name == "EMPIRE STATE CARP" && v == "EMPIRE STATE CARP"||layers[i].name == "FIDELIS HEALTH" && v == "FIDELIS HEALTH"||layers[i].name == "AFFINITY" && v == "AFFINITY"||layers[i].name == "AETNA" && v == "AETNA"||layers[i].name == "FIRST UNITED AMERSUP" && v == "FIRST UNITED AMERSUP"||layers[i].name == "GEHA" && v == "GEHA"||layers[i].name == "GUARDIAN" && v == "GUARDIAN"||layers[i].name == "HEALTHCARE PART IPA" && v == "HEALTHCARE PART IPA"||layers[i].name == "HEALTHFIRST" && v == "HEALTHFIRST"||layers[i].name == "HORIZON HEALTH" && v == "HORIZON HEALTH"||layers[i].name == "HOTEL TRADES UNION" && v == "HOTEL TRADES UNION"||layers[i].name == "HUMANA" && v == "HUMANA"||layers[i].name == "ISLAND GROUP ADMIN" && v == "ISLAND GROUP ADMIN"||layers[i].name == "LIBERTY HEALTH PLAN" && v == "LIBERTY HEALTH PLAN"||layers[i].name == "LOCAL 1199" && v == "LOCAL 1199"||layers[i].name == "MAGELLAN HEALTH" && v == "MAGELLAN HEALTH"||layers[i].name == "MAGNACARE" && v == "MAGNACARE"||layers[i].name == "MAIL HANDLERS" && v == "MAIL HANDLERS"||layers[i].name == "MASTERCARE" && v == "MASTERCARE"||layers[i].name == "MEDICAID" && v == "MEDICAID"||layers[i].name == "MEDICARE" && v == "MEDICARE"||layers[i].name == "MEDICHOICE BEECH ST" && v == "MEDICHOICE BEECH ST"||layers[i].name == "MERCHANT MARINE" && v == "MERCHANT MARINE"||layers[i].name == "MERITAIN HEALTH PLAN" && v == "MERITAIN HEALTH PLAN"||layers[i].name == "METROPLUS" && v == "METROPLUS"||layers[i].name == "MHN" && v == "MHN"||layers[i].name == "MULTIPLAN" && v == "MULTIPLAN"||layers[i].name == "MUTUAL OF OMAHA" && v == "MUTUAL OF OMAHA"||layers[i].name == "NIPPON LIFE" && v == "NIPPON LIFE"||layers[i].name == "NPPN" && v == "NPPN"||layers[i].name == "OSCAR EXCHANGE PLAN" && v == "OSCAR EXCHANGE PLAN"||layers[i].name == "OXFORD HEALTH PLAN" && v == "OXFORD HEALTH PLAN"||layers[i].name == "POMCO" && v == "POMCO"||layers[i].name == "TRANSAMERICA SUPPLE" && v == "TRANSAMERICA SUPPLE"||layers[i].name == "TRICARE" && v == "TRICARE"||layers[i].name == "UMR" && v == "UMR"||layers[i].name == "UNITED AMERICAN SUP" && v == "UNITED AMERICAN SUP"||layers[i].name == "UNITED HEALTHCARE" && v == "UNITED HEALTHCARE"||layers[i].name == "UNITED OPTUM" && v == "UNITED OPTUM"||layers[i].name == "VALUE OPTIONS" && v == "VALUE OPTIONS"||layers[i].name == "WELLCARE" && v == "WELLCARE"){layers[i].state = true;}
          else {layers[i].state = false;}}
      if ( v == "Pick a Payer") {
          this.getField("AARP").display = display.hidden;
          this.getField("AETNA").display = display.hidden; 
          this.getField("AFFINITY EXCHANGE").display = display.hidden;  
          this.getField("AFFINITY HEALTH").display = display.hidden;    
          this.getField("AFFINITY MEDICARE").display = display.hidden;  
          this.getField("AGEWELL").display = display.hidden;
          this.getField("ALICARE").display = display.hidden;    
          this.getField("AMA").display = display.hidden;
          this.getField("AMERICAN PROGRESSIVE").display = display.hidden;
          this.getField("AMERIHEALTH").display = display.hidden; 
          this.getField("APWU").display = display.hidden;  
          this.getField("AXA ASSISTANCE").display = display.hidden;    
          this.getField("BCBS HEALTHPLUS").display = display.hidden;  
          this.getField("BLUE CROSS").display = display.hidden;
          this.getField("C R CONSULTING").display = display.hidden;    
          this.getField("CARECONNECT").display = display.hidden;
          this.getField("CHOICECARE NETWORK").display = display.hidden;
          this.getField("CIGNA HEALTHCARE").display = display.hidden; 
          this.getField("CONNECTICARE").display = display.hidden;  
          this.getField("CONSUMER HEALTH NET").display = display.hidden;    
          this.getField("DEVON HEALTH SERVICE").display = display.hidden;  
          this.getField("DEWITT NURSING HOME").display = display.hidden;
          this.getField("ELDERPLAN").display = display.hidden;    
          this.getField("EMBLEM HEALTH").display = display.hidden;
          this.getField("EMPIRE STATE CARP").display = display.hidden;
          this.getField("FIDELIS HEALTH").display = display.hidden; 
          this.getField("FIRST UNITED AMERSUP").display = display.hidden;  
          this.getField("GEHA").display = display.hidden;    
          this.getField("GUARDIAN").display = display.hidden;  
          this.getField("HEALTHCARE PART IPA").display = display.hidden;
          this.getField("HEALTHFIRST").display = display.hidden;    
          this.getField("HORIZON HEALTH").display = display.hidden;
          this.getField("HOTEL TRADES UNION").display = display.hidden;
          this.getField("HUMANA").display = display.hidden; 
          this.getField("ISLAND GROUP ADMIN").display = display.hidden;  
          this.getField("LIBERTY HEALTH PLAN").display = display.hidden;    
          this.getField("LOCAL 1199").display = display.hidden;  
          this.getField("MAGELLAN HEALTH").display = display.hidden;
          this.getField("MAGNACARE").display = display.hidden;    
          this.getField("MAIL HANDLERS").display = display.hidden;
          this.getField("MASTERCARE").display = display.hidden;
          this.getField("MEDICAID").display = display.hidden; 
          this.getField("MEDICARE").display = display.hidden;  
          this.getField("MEDICHOICE BEECH ST").display = display.hidden;    
          this.getField("MERCHANT MARINE").display = display.hidden;  
          this.getField("MERITAIN HEALTH PLAN").display = display.hidden;
          this.getField("METROPLUS").display = display.hidden;    
          this.getField("MHN").display = display.hidden;
          this.getField("MULTIPLAN").display = display.hidden;
          this.getField("MUTUAL OF OMAHA").display = display.hidden; 
          this.getField("NIPPON LIFE").display = display.hidden;  
          this.getField("NPPN").display = display.hidden;    
          this.getField("OSCAR EXCHANGE PLAN").display = display.hidden;  
          this.getField("OXFORD HEALTH PLAN").display = display.hidden;
          this.getField("POMCO").display = display.hidden;    
          this.getField("TRANSAMERICA SUPPLE").display = display.hidden;
          this.getField("TRICARE").display = display.hidden;
          this.getField("UMR").display = display.hidden; 
          this.getField("UNITED AMERICAN SUP").display = display.hidden;  
          this.getField("UNITED HEALTHCARE").display = display.hidden;    
          this.getField("UNITED OPTUM").display = display.hidden;  
          this.getField("VALUE OPTIONS").display = display.hidden;
          this.getField("WELLCARE").display = display.hidden;    
          this.getField("AVAILITY").display = display.hidden;    
          this.getField("NAVINET").display = display.hidden; 
          this.getField("EMDEON").display = display.hidden; 
      }
      else if (v == "AARP") {
          this.getField("AARP").display = display.visible;
          this.getField("AETNA").display = display.hidden; 
          this.getField("AFFINITY EXCHANGE").display = display.hidden;  
          this.getField("AFFINITY HEALTH").display = display.hidden;    
          this.getField("AFFINITY MEDICARE").display = display.hidden;  
          this.getField("AGEWELL").display = display.hidden;
          this.getField("ALICARE").display = display.hidden;    
          this.getField("AMA").display = display.hidden;
          this.getField("AMERICAN PROGRESSIVE").display = display.hidden;
          this.getField("AMERIHEALTH").display = display.hidden; 
          this.getField("APWU").display = display.hidden;  
          this.getField("AXA ASSISTANCE").display = display.hidden;    
          this.getField("BCBS HEALTHPLUS").display = display.hidden;  
          this.getField("BLUE CROSS").display = display.hidden;
          this.getField("C R CONSULTING").display = display.hidden;    
          this.getField("CARECONNECT").display = display.hidden;
          this.getField("CHOICECARE NETWORK").display = display.hidden;
          this.getField("CIGNA HEALTHCARE").display = display.hidden; 
          this.getField("CONNECTICARE").display = display.hidden;  
          this.getField("CONSUMER HEALTH NET").display = display.hidden;    
          this.getField("DEVON HEALTH SERVICE").display = display.hidden;  
          this.getField("DEWITT NURSING HOME").display = display.hidden;
          this.getField("ELDERPLAN").display = display.hidden;    
          this.getField("EMBLEM HEALTH").display = display.hidden;
          this.getField("EMPIRE STATE CARP").display = display.hidden;
          this.getField("FIDELIS HEALTH").display = display.hidden; 
          this.getField("FIRST UNITED AMERSUP").display = display.hidden;  
          this.getField("GEHA").display = display.hidden;    
          this.getField("GUARDIAN").display = display.hidden;  
          this.getField("HEALTHCARE PART IPA").display = display.hidden;
          this.getField("HEALTHFIRST").display = display.hidden;    
          this.getField("HORIZON HEALTH").display = display.hidden;
          this.getField("HOTEL TRADES UNION").display = display.hidden;
          this.getField("HUMANA").display = display.hidden; 
          this.getField("ISLAND GROUP ADMIN").display = display.hidden;  
          this.getField("LIBERTY HEALTH PLAN").display = display.hidden;    
          this.getField("LOCAL 1199").display = display.hidden;  
          this.getField("MAGELLAN HEALTH").display = display.hidden;
          this.getField("MAGNACARE").display = display.hidden;    
          this.getField("MAIL HANDLERS").display = display.hidden;
          this.getField("MASTERCARE").display = display.hidden;
          this.getField("MEDICAID").display = display.hidden; 
          this.getField("MEDICARE").display = display.hidden;  
          this.getField("MEDICHOICE BEECH ST").display = display.hidden;    
          this.getField("MERCHANT MARINE").display = display.hidden;  
          this.getField("MERITAIN HEALTH PLAN").display = display.hidden;
          this.getField("METROPLUS").display = display.hidden;    
          this.getField("MHN").display = display.hidden;
          this.getField("MULTIPLAN").display = display.hidden;
          this.getField("MUTUAL OF OMAHA").display = display.hidden; 
          this.getField("NIPPON LIFE").display = display.hidden;  
          this.getField("NPPN").display = display.hidden;    
          this.getField("OSCAR EXCHANGE PLAN").display = display.hidden;  
          this.getField("OXFORD HEALTH PLAN").display = display.hidden;
          this.getField("POMCO").display = display.hidden;    
          this.getField("TRANSAMERICA SUPPLE").display = display.hidden;
          this.getField("TRICARE").display = display.hidden;
          this.getField("UMR").display = display.hidden; 
          this.getField("UNITED AMERICAN SUP").display = display.hidden;  
          this.getField("UNITED HEALTHCARE").display = display.hidden;    
          this.getField("UNITED OPTUM").display = display.hidden;  
          this.getField("VALUE OPTIONS").display = display.hidden;
          this.getField("WELLCARE").display = display.hidden;    
          this.getField("AVAILITY").display = display.hidden;    
          this.getField("NAVINET").display = display.hidden; 
          this.getField("EMDEON").display = display.visible;
      }
      

      in this format it is far too large. I need away to set only the buttons/fields I need to visible and to make all else hidden.

       

      Thanks in advance for your help.

        • 1. Re: Show Hide Many Fields based on Drop Down Selection
          gkaiseril MVP & Adobe Community Professional

          I would look at using control loops to access the fields based on the field names in an array of field names to be processed.

           

          I would also use an external text editor. This can be done by changing the choice for the editor in the "JavaScript" category for Acrobat's "Preferences".

          • 2. Re: Show Hide Many Fields based on Drop Down Selection
            MikeLiff82 Level 1

            Thanks for the advice!

            I am currently using an external text editor. It has been very helpful.

            do you think you could be a bit more specific regarding using arrays?  I attempted to use an array but I could not build an array of fields.

            for (var i = 0; i < this.getArray.length; i++){if (payerArray[i].name == "AARP" && v == "AARP"||layers[i].name == "AETNA" && v == "AETNA"||layers[i].name == "AFFINITY EXCHANGE" && v == "AFFINITY EXCHANGE"||layers[i].name == "AFFINITY HEALTH" && v == "AFFINITY HEALTH"||layers[i].name == "AFFINITY MEDICARE" && v == "AFFINITY MEDICARE"||layers[i].name == "AGEWELL" && v == "AGEWELL"||layers[i].name == "ALICARE" && v == "ALICARE"||layers[i].name == "AMERICAN PROGRESSIVE" && v == "AMERICAN PROGRESSIVE"||layers[i].name == "AMERIHEALTH" && v == "AMERIHEALTH"||layers[i].name == "APWU" && v == "APWU"||layers[i].name == "AXA ASSISTANCE" && v == "AXA ASSISTANCE"||layers[i].name == "BCBS HEALTHPLUS" && v == "BCBS HEALTHPLUS"||layers[i].name == "BLUE CROSS" && v == "BLUE CROSS"||layers[i].name == "C R CONSULTING" && v == "C R CONSULTING"||layers[i].name == "CARECONNECT" && v == "CARECONNECT"||layers[i].name == "CHOICECARE NETWORK" && v == "CHOICECARE NETWORK"||layers[i].name == "CIGNA HEALTHCARE" && v == "CIGNA HEALTHCARE"||layers[i].name == "CONNECTICARE" && v == "CONNECTICARE"||layers[i].name == "CONSUMER HEALTH NET" && v == "CONSUMER HEALTH NET"||layers[i].name == "DEVON HEALTH SERVICE" && v == "DEVON HEALTH SERVICE"||layers[i].name == "DEWITT NURSING HOME" && v == "DEWITT NURSING HOME"||layers[i].name == "ELDERPLAN" && v == "ELDERPLAN"||layers[i].name == "EMBLEM HEALTH" && v == "EMBLEM HEALTH"||layers[i].name == "EMPIRE STATE CARP" && v == "EMPIRE STATE CARP"||layers[i].name == "FIDELIS HEALTH" && v == "FIDELIS HEALTH"||layers[i].name == "AFFINITY" && v == "AFFINITY"||layers[i].name == "AETNA" && v == "AETNA"||layers[i].name == "FIRST UNITED AMERSUP" && v == "FIRST UNITED AMERSUP"||layers[i].name == "GEHA" && v == "GEHA"||layers[i].name == "GUARDIAN" && v == "GUARDIAN"||layers[i].name == "HEALTHCARE PART IPA" && v == "HEALTHCARE PART IPA"||layers[i].name == "HEALTHFIRST" && v == "HEALTHFIRST"||layers[i].name == "HORIZON HEALTH" && v == "HORIZON HEALTH"||layers[i].name == "HOTEL TRADES UNION" && v == "HOTEL TRADES UNION"||layers[i].name == "HUMANA" && v == "HUMANA"||layers[i].name == "ISLAND GROUP ADMIN" && v == "ISLAND GROUP ADMIN"||layers[i].name == "LIBERTY HEALTH PLAN" && v == "LIBERTY HEALTH PLAN"||layers[i].name == "LOCAL 1199" && v == "LOCAL 1199"||layers[i].name == "MAGELLAN HEALTH" && v == "MAGELLAN HEALTH"||layers[i].name == "MAGNACARE" && v == "MAGNACARE"||layers[i].name == "MAIL HANDLERS" && v == "MAIL HANDLERS"||layers[i].name == "MASTERCARE" && v == "MASTERCARE"||layers[i].name == "MEDICAID" && v == "MEDICAID"||layers[i].name == "MEDICARE" && v == "MEDICARE"||layers[i].name == "MEDICHOICE BEECH ST" && v == "MEDICHOICE BEECH ST"||layers[i].name == "MERCHANT MARINE" && v == "MERCHANT MARINE"||layers[i].name == "MERITAIN HEALTH PLAN" && v == "MERITAIN HEALTH PLAN"||layers[i].name == "METROPLUS" && v == "METROPLUS"||layers[i].name == "MHN" && v == "MHN"||layers[i].name == "MULTIPLAN" && v == "MULTIPLAN"||layers[i].name == "MUTUAL OF OMAHA" && v == "MUTUAL OF OMAHA"||layers[i].name == "NIPPON LIFE" && v == "NIPPON LIFE"||layers[i].name == "NPPN" && v == "NPPN"||layers[i].name == "OSCAR EXCHANGE PLAN" && v == "OSCAR EXCHANGE PLAN"||layers[i].name == "OXFORD HEALTH PLAN" && v == "OXFORD HEALTH PLAN"||layers[i].name == "POMCO" && v == "POMCO"||layers[i].name == "TRANSAMERICA SUPPLE" && v == "TRANSAMERICA SUPPLE"||layers[i].name == "TRICARE" && v == "TRICARE"||layers[i].name == "UMR" && v == "UMR"||layers[i].name == "UNITED AMERICAN SUP" && v == "UNITED AMERICAN SUP"||layers[i].name == "UNITED HEALTHCARE" && v == "UNITED HEALTHCARE"||layers[i].name == "UNITED OPTUM" && v == "UNITED OPTUM"||layers[i].name == "VALUE OPTIONS" && v == "VALUE OPTIONS"||layers[i].name == "WELLCARE" && v == "WELLCARE"){this.getArray[i].display = display.visible;}
            else {this.getArray[i].display = display.hidden;}}
            
            • 3. Re: Show Hide Many Fields based on Drop Down Selection
              gkaiseril MVP & Adobe Community Professional

              You need to define an array of the  field names.

               

              ".getArray" is usually used with hierarchical field names to get the array of child field objects under a parent field.