8 Replies Latest reply on Mar 28, 2013 2:14 PM by Markojett

    Script Needed

    Markojett

      I need a script for an Adobe form I'm making, and I can't seem to figure it out. What I need is something that will say: If checkbox "a" is checked & checkbox "b" is unchecked, then field "c" will be hidden. I've tried several but I can't seem to get this to work.

        • 1. Re: Script Needed
          George_Johnson MVP & Adobe Community Professional

          If field c is a text field, you can use the following as its custom calculation scipt:

           

          (function () {

           

              // Get the values of the check boxes

              var v1 = getField("cb_a").value;

              var v2 = getField("cb_b").value;

           

              // Set this field's visiblility

              event.target.display = v1 !== "Off" && v2 === "Off" ? display.hidden : display.visible;

           

          })();

           

           

          You should consider clearing the value whenever the field is hidden as well. To do this you'd replace that last line with:

           

              if (v1 !== "Off" && v2 === "Off") {

                  event.value = "";

                  event.target.display = display.hidden;

              } else {

                  event.target.display = display.visible;

              }

          • 2. Re: Script Needed
            Markojett Level 1

            Thank you George - You always have great information. One question: It is a text field & I already have a custom calculation script in this field. Is it possible to add a second?

            • 3. Re: Script Needed
              George_Johnson MVP & Adobe Community Professional

              It should be combined into a single script. What are you using?

              • 4. Re: Script Needed
                Markojett Level 1

                It's just a script pulling info from another field & adding periods for a phone number:

                 

                event.value=getField

                ("Office#").valueAsString+(".")+getField

                ("Office#1").valueAsString+(".")+getField

                ("Office#2").valueAsString

                • 5. Re: Script Needed
                  George_Johnson MVP & Adobe Community Professional

                  OK, so the entire single script can be:

                   

                  (function () {

                   

                      // Get the values of the check boxes

                      var v1 = getField("cb_a").value;

                      var v2 = getField("cb_b").value;

                   

                      // Set this field's visiblility

                      event.target.display = v1 !== "Off" && v2 === "Off" ? display.hidden : display.visible;

                   

                       // Set this field's value

                      event.value = getField("Office#").valueAsString + (".") + getField("Office#1").valueAsString + (".") + getField("Office#2").valueAsString;

                   

                  })();

                  • 6. Re: Script Needed
                    Markojett Level 1

                    So what should the export values be for my 2 checkboxes?

                    • 7. Re: Script Needed
                      George_Johnson MVP & Adobe Community Professional

                      It doesn't matter with this code. It checks to see if they're not selected ("Off"). You will of course have to change the field names from "cb_a" and "cb_b" to match what you're using.

                      • 8. Re: Script Needed
                        Markojett Level 1

                        Fantastic George - Thank you so much!!