2 Replies Latest reply on Oct 24, 2015 3:11 AM by alpharipper

    Java (PDF) two drop down menus showing results in text box.

    alpharipper

      I am in desperate need of some help. I need a script for PDF to allow me to select items from two drop down boxes and give result in text box (?). I have to calculate risk on a risk matrix, eg one box is A to E and the other is 1 to 5. the results need to be eg B2 Low (showing low risk but also in a colour eg green for low. I have read heap and have confused myself and totally lost. Your help is appreciated in advance. Thank you

       

      I also appreciate this has probably been covered but as I said I am confused and lost after reading many examples.

       

      Happy to try anyway that someone offers. Just need this form to work.

        • 1. Re: Java (PDF) two drop down menus showing results in text box.
          try67 MVP & Adobe Community Professional

          Here's a script that demonstrates how to do it:

           

          // Combine both values to a single variable
          var a = this.getField("Risk1").valueAsString;
          var b = this.getField("Risk2").valueAsString;
          var c = a+b;
          
          // Determine the field's fill color based on that variable
          if (c=="A1") event.target.fillColor = color.red;
          if (c=="B2") event.target.fillColor = color.green; // etc.
          else event.target.fillColor = color.white;
          
          // Set the field's value to the combined value
          event.value = c;
          

           

          Place this code as the custom calculation script of your text field.

          Of course, you'll need to adjust the field names used, and add more lines to cover all of the possible combinations for the fill color.

          • 2. Re: Java (PDF) two drop down menus showing results in text box.
            alpharipper Level 1

            Thank you so much, I was totally on the wrong track but its clear now what I should have been doing.  I also will work on getting an extra line of text in eg, if  A1, change to red and list risk LOW. Color change in text box is working.

             

            Thank you again.