1 Reply Latest reply on Dec 19, 2016 10:44 AM by gkaiseril

    I need another way to run this code


      First I am a novice at best...but learning


      I have a form that has a worksheet the user will complete prior to filling out the form. The worksheet is a series of 71 check boxes that will assign a category value...1, 2, or 3, and populate 1 or more text boxes with different instructions.


      There are 15 discreet groups of category and text box combinations possible depending on which checkbox is selected.

      Check boxes are named cbGroup1.1, cbGroup1.2....cbGroup15.1...


      The function below is called from a mouseup event in the checkbox field.


      function setText(){

      if (this.getField('cbGroup1.3').value == 'Yes') {

        this.getField('rptCategory').value = 'CATEGORY 1';

        this.getField('rptInfo.1').value = 'Instruction one';

        this.getField('rptInfo.1').display = display.visible;

        this.getField('rptInfo.2').value = 'Instruction two';

        this.getField('rptInfo.2').display = display.visible;

        this.getField('rptInfo.3').value = 'Instruction three';

        this.getField('rptInfo.3').display = display.visible;

        this.getField('rptInfo.5').value = 'Instruction four';

        this.getField('rptInfo.5').display = display.visible;

        this.getField('rptInfo.6').value = 'Instruction five';

        this.getField('rptInfo.6').display = display.visible;

        this.getField('rptInfo.7').value = 'Instruction six';

        this.getField('rptInfo.7').display = display.visible;

        this.getField('rptInfo.9').value = 'Instruction seven';

        this.getField('rptInfo.9').display = display.visible


      if (this.getField('cbGroup1.3').value == 'Off') {

        this.getField('rptCategory').value = '';

        this.getField('rptInfo.1').value = '';

        this.getField('rptInfo.1').display = display.hidden;

        this.getField('rptInfo.2').value = '';

        this.getField('rptInfo.2').display = display.hidden;

        this.getField('rptInfo.3').value = '';

        this.getField('rptInfo.3').display = display.hidden;

        this.getField('rptInfo.4').value = '';

        this.getField('rptInfo.4').display = display.hidden;

        this.getField('rptInfo.5').value = '';

        this.getField('rptInfo.5').display = display.hidden;

        this.getField('rptInfo.6').value = '';

        this.getField('rptInfo.6').display = display.hidden;

        this.getField('rptInfo.7').value = '';

        this.getField('rptInfo.7').display = display.hidden;

        this.getField('rptInfo.8').value = '';

        this.getField('rptInfo.8').display = display.hidden;

        this.getField('rptInfo.9').value = '';

        this.getField('rptInfo.9').display = display.hidden;

        this.getField('rptInfo.10').value = '';

        this.getField('rptInfo.10').display = display.hidden;

        this.getField('rptInfo.11').value = '';

        this.getField('rptInfo.11').display = display.hidden



      With the above I would need over a 1000 lines of code to run this...Is there a better way to do this?

        • 1. Re: I need another way to run this code
          gkaiseril MVP & Adobe Community Professional

          I would look at using a "for" loop. Since the field names are hierarchical you can use the ending ".#" as the control counter and compute the string for the field name. It would even  be possible to create a variable object for the parent name and then use the "getArray()" method to create an array object that contains all the child field objects.


          You can even write a function that will convert a number to the word for that number.


          If you are using a mobile device the above approach most likely will not available since most mobile devices do not support all the features of Acrobat JavaScript.