3 Replies Latest reply on Apr 4, 2008 11:24 AM by (Larissa_Velez)

    Auto-select Checkbox Based Off Sum of Numeric Text Felds

      I am working on a form for the HR department to allow managers to fill out performance reviews.

      There are boxes next to performance levels ranging from 1-5.

      After about 10 questions, the sum of those boxes should select the appropriate "performance rating" checkbox.

      If the sum of the 10 boxes is 0-1.75, then select the "needs improvement" check box...and so forth.

      I've attempted the FormCalc and some JS, but to no avail.

      I've gone to "Scripting Reference" option under LiveCycle's "Help" menu option, but I cannot seem to understand.

      Please can someone make sense of this so I do not find the roof access and walk to the edge.

      Thanx!!
        • 1. Re: Auto-select Checkbox Based Off Sum of Numeric Text Felds
          I am working on the exact same thing, and as far as I can tell, after four days of reading forums and Java books the only way to get this to happen is to have hidden fields that will show based on the value of what is in the sum field. But I don't know if Acrobat can recognize what is in that field as anything but code. I don't know if it will see - "25" and know what to do. I haven't seen anything in forums that indicates it can do that, if anyone knows if it is possible, any help would be appreciated. My form has a grid and I want a color bar to appear at the appropriate level based on the grade in the sum field. I am stuck (frustrated) - can someone help??
          • 2. Re: Auto-select Checkbox Based Off Sum of Numeric Text Felds
            gkaiseril MVP & Adobe Community Professional
            Both Acro Forms and LiveCycle Designer support "if" statements and hidden fields.

            One also needs to understand there is a difference between a character number stirng and a number. Even though the look the same, they are handled very differently in many programing envrionments. JavaScript and FormCalc are not very strict about this which causes a lot of confusion becuase sometimes code works and sometimes it does not dependent on the version of Acrobat/Reader is being used. So you should make sure the two items you are coparing are either stirngs or numbers.

            Hiding and Showing Form Fields by Thom Parker
            http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/show_hide_fields/
            • 3. Re: Auto-select Checkbox Based Off Sum of Numeric Text Felds
              Level 1
              Thank you, I have Acro 7 Pro as well as v8 (for this form I am using 7) and I am using LiveCycle to create this form. I have a field titled Score[0] which is a numeric field that is generating a sum of two other fields, then I have 15 other numeric fields titled NumericField1 through NumericField15, there isn't anything in the fields it's just there to show a "You are here" as the field title above a certain point on the page, I have the entry side of the field completely sized down. I looked at the link you provided and that person is editing the fields using the Select tool, which is grayed out in mine...don't know why. But I should be able to write this code in LiveCycle script editor, so I don't think that matters. What I want is for NumericField1 to appear when the sum in Score reaches 0-10, NumericField2 to appear when the sum reaches 11-20, etc. Otherwise I want them to be hidden. I know this is a very simple script and I have seen numerous examples of something similar, but I am new to Java and FormCalc and I am not sure how to begin the script or which event handler to associate it with (initialize, validate, enter, exit...). I need a starting point to tell "Score" to get NumericField1 to appear based on the numeric value that is returned in the Score field. I looked at some other postings you have and thought either of the following would work, but nothing happens (you wrote these in earlier posts) and I changed the field names to match mine:

              1.

              >if (event.value > 20) {getField("NumericField1").textColor = color.black;}
              else {getField("NumericField1").textColor = color.white;}

              Which is here:
              http://www.adobeforums.com/webx?224@@ef728db@.59b4c293

              2.

              >// hide all text fields
              this.getField("text.0").display = display.hidden;
              this.getField("text.1").display = display.hidden;
              this.getField("text.2").display = display.hidden;
              // or
              this.getField("text").display = display.hidden;

              >// what is the value of the selection
              switch(event.value) {

              >case "Off":
              // all off by default
              break;

              >case "0": // box 1 selected
              this.getField("text.0").display = display.visible;
              break;

              >case "1": // box 2 is selected
              this.getField("text.1").display = display.visible;
              break;

              >case "2": // box 3 is selected
              this.getField("text.2").display = display.visible;
              break;

              >default: // unknown selection
              app.alert("Unknown selection");
              break;
              }

              Which is here:
              http://www.adobeforums.com/webx?224@@2cda594e@.3bc3beb7

              Am I off base here?