7 Replies Latest reply on Dec 13, 2017 2:03 AM by try67

    Javascript modification?

    pdfUser1 Level 1

      I have 3 drop downs and I'm using this script to make them readonly and not,

       

      if (event.value == "")

      {

       

      this.getField("TranChec").readonly = true;

      this.getField("Tran1Htb").readonly = true;

      this.getField("width").readonly = true;

      this.getField("TranChec").value = "Off";

      this.resetForm(["Text2bbb","Text22b"]);

      }

      if (event.value == "1")

      {

       

      this.getField("TranChec").readonly = false;

      this.getField("Tran1Htb").readonly = false;

      this.getField("width").readonly = false;

       

      }

       

      else if (event.value == "2")

      {

      this.getField("TranChec").readonly = false;

      this.getField("Tran1Htb").readonly = false;

      this.getField("width").readonly = false;

       

      }

      //the script goes up to 50.

       

      What I would like to do is to eliminate all this script because at times I have to enter a number above 50 in the first drop down. At the moment when I enter a number higher than 50 the other two drop downs remain readonly. So, I'd like to be able to enter any number and the other two drop downs will become accessible and will become readonly on reset. Can someone help me with this problem and tell me how to modify this script? Thanks guys.

        • 1. Re: Javascript modification?
          Test Screen Name Most Valuable Participant

          Are you wanting to do exactly the same thing for every case where event.value is not blank? Or only the cases where it is a positive number (more than zero)?

          • 2. Re: Javascript modification?
            pdfUser1 Level 1

            well, the main drop down has just numbers. The first option is blank. The second option is "1", the third option is "2", etc. At the moment I have a list of 50. The sample script I provided goes up to 50. The problem is, if I enter a number above 50 the other two drop downs remain readonly. Kinda limits me to only 50. I don't want have to create a long list of 1000 options to be able to make the two drop downs accessible.

             

            What I'm trying to do, (if it possible) is to be able to make the second and third drop down readonly when I reset the first drop down but to make the two other drop downs accessible when I enter ANY number in the first one. I hope that explains it enough. I thought the sample script above would.

            • 3. Re: Javascript modification?
              Test Screen Name Most Valuable Participant

              So there is no difference at all between what you want to do when 1 is entered, or 2 or 3 or 50 or 76?

              • 4. Re: Javascript modification?
                pdfUser1 Level 1

                Right. So, I found this script,

                 

                if (event.value >= 1) (this.getField("TranChec").readonly = false);

                else (this.getField("TranChec").readonly = true);

                 

                if (event.value >= 1) (this.getField("Tran1Htb").readonly = false);

                else (this.getField("Tran1Htb").readonly = true);

                 

                if (event.value >= 1) (this.getField("width").readonly = false);

                else (this.getField("width").readonly = true);

                 

                this seems to work. I placed it into the Validate window of the first drop down and it makes them readonly when I reset and accessible when I select a number (1 or greater). I just have to play around with it a little. But, thanks for your time.

                • 5. Re: Javascript modification?
                  try67 MVP & Adobe Community Professional

                  There's no need to repeat the same if-condition. Use this instead:

                   

                  if (event.value >= 1) {

                      this.getField("TranChec").readonly = false;

                      this.getField("Tran1Htb").readonly = false;

                      this.getField("width").readonly = false;

                  } else {

                      this.getField("TranChec").readonly = true;

                      this.getField("Tran1Htb").readonly = true;

                      this.getField("width").readonly = true;

                  }

                  • 6. Re: Javascript modification?
                    pdfUser1 Level 1

                    I see. Thanks for your help. The script works fine. I just don't know enough about script (but learning everyday) to know how to script it another way.

                     

                    I also have to include a reset for certain fields. How would I include that? Where would it go?

                    • 7. Re: Javascript modification?
                      try67 MVP & Adobe Community Professional

                      Where it would go depends on when you want to execute it, but the command is this:

                      this.resetForm(["Field1", "Field2", "Field3"]);

                      If you want to reset the entire file use this:

                      this.resetForm();

                      1 person found this helpful