8 Replies Latest reply on Apr 27, 2016 1:35 PM by madeleinel22391508

    readonly vs. hidden, simplifying java, global organization of adobe form

    madeleinel22391508 Level 1

      Hello,

       

      I am very new to java and adobe acrobat.  I have a form in which clients are separated into 3 types and depending on what type of client they are areas of the form do not need to be filled out. The form unfortunately, is long and complicated with multiple scenarios for example if they are an individual investor vs. a corporate investor different fields need to be filled out and if they are a corporate investor and located in BC (both scenarios) then different fields need to be completed. There is quite a few fields (50+) that change and although my code is working (mostly) it is bulky and I feel that it could be better thought through/organized/possibly using incorrect commands for the situation. My question is two fold:  For making text boxes, drop boxes, and radio buttons when is it best to use hidden vs visible, and read-only true/false (and possibly other commands that I am unaware of)? My second question is how do I simplify my code to prevent mistakes and make changes easier. At the moment I am finding I change one thing and it effects 4 other things that I didn't want it to effect.  For example, I have the three client types as a radio button individual, joint, corporation do I place this code into into each button so that if they click through (change their answer) it always opens the right fields or is it their a better way to think about it.  This is my code right now for example for the individual choice:

       

      {

         var v = this.getField("InvestorType").value;

       

       

         if (v == "Individual")

         {

            this.getField("CorpType").display = display.hidden;

            this.getField("Salutation").display = display.visible;

            this.getField("Surname").display = display.visible;

            this.getField("FName").display = display.visible;

            this.getField("Street").display = display.visible;

            this.getField("City").display = display.visible;

            this.getField("Province").display = display.visible;

            this.getField("PostalCode").display = display.visible;

            this.getField("Telephone").display = display.visible;

            this.getField("Fax").display = display.visible;

            this.getField("Email").display = display.visible;

            this.getField("Occupation").display = display.visible;

            this.getField("BirthDate").display = display.visible;

            this.getField("Employer").display = display.visible;

            this.getField("SIN").display = display.visible;

            this.getField("License").display = display.visible;

            this.getField("BirthCert").display = display.visible;

            this.getField("Passport").display = display.visible;

           

            this.getField("Salutation_J").display = display.hidden;

            this.getField("Surname_J").display = display.hidden;

            this.getField("FName_J").display = display.hidden;

            this.getField("Street_J").display = display.hidden;

            this.getField("City_J").display = display.hidden;

            this.getField("Province_J").display = display.hidden;

            this.getField("PostalCode_J").display = display.hidden;

            this.getField("Telephone_J").display = display.hidden;

            this.getField("Fax_J").display = display.hidden;

            this.getField("Email_J").display = display.hidden;

            this.getField("Occ_J").display = display.hidden;

            this.getField("BirthDate_J").display = display.hidden;

            this.getField("Employer_J").display = display.hidden;

            this.getField("SIN_J").display = display.hidden;

            this.getField("License_J").display = display.hidden;

            this.getField("BirthCert_J").display = display.hidden;

            this.getField("Passport_J").display = display.hidden;

           

            this.getField("Name_C").display = display.hidden;

            this.getField("Address_C").display = display.hidden;

            this.getField("City_C").display = display.hidden;

            this.getField("Province_C").display = display.hidden;

            this.getField("PostalCode_C").display = display.hidden;

            this.getField("Telephone_C").display = display.hidden;

            this.getField("Fax_C").display = display.hidden;

            this.getField("Email_C").display = display.hidden;

            this.getField("PrincipalBus").display = display.hidden;

            this.getField("BIN").display = display.hidden;

      }

       

       

      else if (v== "Joint")

       

       

         {

            this.getField("Salutation").display = display.visible;

            this.getField("Surname").display = display.visible;

            this.getField("FName").display = display.visible;

            this.getField("Street").display = display.visible;

            this.getField("City").display = display.visible;

            this.getField("Province").display = display.visible;

            this.getField("PostalCode").display = display.visible;

            this.getField("Telephone").display = display.visible;

            this.getField("Fax").display = display.visible;

            this.getField("Email").display = display.visible;

            this.getField("Occupation").display = display.visible;

            this.getField("BirthDate").display = display.visible;

            this.getField("Employer").display = display.visible;

            this.getField("SIN").display = display.visible;

            this.getField("License").display = display.visible;

            this.getField("BirthCert").display = display.visible;

            this.getField("Passport").display = display.visible;

            this.getField("Salutation_J").display = display.visible;

           

            this.getField("Surname_J").display = display.visible;

            this.getField("FName_J").display = display.visible;

            this.getField("Street_J").display = display.visible;

            this.getField("City_J").display = display.visible;

            this.getField("Province_J").display = display.visible;

            this.getField("PostalCode_J").display = display.visible;

            this.getField("Telephone_J").display = display.visible;

            this.getField("Fax_J").display = display.visible;

            this.getField("Email_J").display = display.visible;

            this.getField("Occ_J").display = display.visible;

            this.getField("BirthDate_J").display = display.visible;

            this.getField("Employer_J").display = display.visible;

            this.getField("SIN_J").display = display.visible;

            this.getField("License_J").display = display.visible;

            this.getField("BirthCert_J").display = display.visible;

            this.getField("Passport_J").display = display.visible;

           

            this.getField("CorpType").display = display.hidden;

            this.getField("Name_C").display = display.hidden;

            this.getField("Address_C").display = display.hidden;

            this.getField("City_C").display = display.hidden;

            this.getField("Province_C").display = display.hidden;

            this.getField("PostalCode_C").display = display.hidden;

            this.getField("Telephone_C").display = display.hidden;

            this.getField("Fax_C").display = display.hidden;

            this.getField("Email_C").display = display.hidden;

            this.getField("PrincipalBus").display = display.hidden;

            this.getField("BIN").display = display.hidden;

         }

       

       

      else if (v=="Corp")

       

       

      function updateFormField()

      {

         var v = this.getField("InvestorType").value;

       

         if (v == "Corp")

         {

            this.getField("CorpType").display = display.visible;    

           

            this.getField("Salutation").display = display.hidden;

            this.getField("Surname").display = display.hidden;

            this.getField("FName").display = display.hidden;

            this.getField("Street").display = display.hidden;

            this.getField("City").display = display.hidden;

            this.getField("Province").display = display.hidden;

            this.getField("PostalCode").display = display.hidden;

            this.getField("Telephone").display = display.hidden;

            this.getField("Fax").display = display.hidden;

            this.getField("Email").display = display.hidden;

            this.getField("Occupation").display = display.hidden;

            this.getField("BirthDate").display = display.hidden;

            this.getField("Employer").display = display.hidden;

            this.getField("SIN").display = display.hidden;

            this.getField("License").display = display.hidden;

            this.getField("BirthCert").display = display.hidden;

            this.getField("Passport").display = display.hidden;

           

            this.getField("Salutation_J").display = display.hidden;

            this.getField("Surname_J").display = display.hidden;

            this.getField("FName_J").display = display.hidden;

            this.getField("Street_J").display = display.hidden;

            this.getField("City_J").display = display.hidden;

            this.getField("Province_J").display = display.hidden;

            this.getField("PostalCode_J").display = display.hidden;

            this.getField("Telephone_J").display = display.hidden;

            this.getField("Fax_J").display = display.hidden;

            this.getField("Email_J").display = display.hidden;

            this.getField("Occ_J").display = display.hidden;

            this.getField("BirthDate_J").display = display.hidden;

            this.getField("Employer_J").display = display.hidden;

            this.getField("SIN_J").display = display.hidden;

            this.getField("License_J").display = display.hidden;

            this.getField("BirthCert_J").display = display.hidden;

            this.getField("Passport_J").display = display.hidden;

       

       

      }

      }

      }

      updateFormField()

       

      Is there a way to simplify this? Any help is much appreciated! Apologies for the wall of text.