1 Reply Latest reply on May 23, 2016 6:50 PM by gkaiseril

    Script help using item value to make fields required and display

    yohjp

      So I have a combo box that has five items listed (text a, text b,.....) and all the values happen to be 50.

       

      I then have a hidden text field become visible and required when text a is selected. Problem is the script I am using is calculating based off the value (30), and sense all are (30), is there a way to use the item list (name) instead? Or a way to make this work?

       

      Custom calculation script for text field

       

      var d=this.getField("combo1").value;

      if (d=="30")

      {

      event.target.display=display.visible;

      event.target.required=true;

      }

      else

      {

      event.target.display=display.hidden;

      event.target.required=false;

      }

        • 1. Re: Script help using item value to make fields required and display
          gkaiseril MVP & Adobe Community Professional

          Do understand what the value of the combo box will  be when an item is selected and you have the "Optional Value" filled in?

           

          Do you think you the value of the field will ever be 30 with your approach?

           

          Have you considered adding some debugging statements your code to see what is happening?

           

          Why are you using quotation marks around a number constant?

          You only need quotation marks around character strings.

           

          var d=this.getField("combo1").value;(;

           

          console.show();

          console.clear();

          console.println("combo1 value: " + d)

          console.println("d == 30: " + (d == 30);

           

          if (d=="30")

          {

          event.target.display=display.visible;

          event.target.required=true;

          }

          else

          {

          event.target.display=display.hidden;

          event.target.required=false;

          }