3 Replies Latest reply on Jan 12, 2010 9:51 AM by DanMun

    check box calculations

    DanMun

      It was pointed out that I should post this message in this scripting forum for some help.

       

      I am not very adept at calculations in form fields.  I would like to automatically check a check box based on a numeric range of a text box:

       

      Moderate (6-10 pts) ) (checbox1)                                                                                                                                                           

      High (11-18 pts)  (checbox2)                                                                                                                         

      Extreme (19 pts and above) (checbox3)

      If the value of the text box is within these ranges the check box would automatically be checked.  Seems simple enough-but I can't figure it out.

      I attached the form

        • 1. Re: check box calculations
          gkaiseril MVP & Adobe Community Professional

          As previously explained, using check boxes with the same name and different export values creates an exclusionary group. Exclusionary groups allow for only one check box within the group to be checked.

           

          You can use a custom calculation script to sum the evaluation values and then set the exclusionary group for the Risk Category by setting the value for the assessed value.

          • 2. Re: check box calculations
            MarkWalsh Level 4

            As GKaiseril mentioned, you need to give all of the checkboxes the same name, but different export values (in the following code, I use the name 'CheckBox'). Set the export values to 'Extreme', 'High' and 'Moderate', then put the following code in the LostFocus event (or the validate event, not esure which is best) of your text field:

             

             

            var currentValue = event.target.value;


            if (currentValue == "") {
                this.getField("CheckBox").value = ""
            }else if (currentValue >= 19) {
                this.getField("CheckBox").value = "Extreme"
            }else if (currentValue >= 11) {
                this.getField("CheckBox").value = "High"
            }else if (currentValue >= 6) {
                this.getField("CheckBox").value = "Moderate"
            } else {
                this.getField("CheckBox").value = "Low"
            }

            • 3. Re: check box calculations
              DanMun Level 1

              Thank you very much-I have to tweak the values a little bit, but the

              script and the concept are flawless.  I put it in the validation area.

               

              Thank yo so much!!!