1 Reply Latest reply on May 29, 2009 6:51 AM by gkaiseril

    If field value is >1 go to another field

    AnjaDisseldorp

      I hope someone can help me with this question

       

      If a client fills in a field with a number that is > 1, I want the cursor to go automatically to another field.

       

      I used the script:

       

      var aant = this.getField("Aantal")
      If (aant != 1)
      {
      this.getField("Naam intro").setFocus();
      }

      But that's not working.

       

      Hope to hear from you. Thanks in advanced.

        • 1. Re: If field value is >1 go to another field
          gkaiseril MVP & Adobe Community Professional

          Are you getting any error messages in the JavaScript debugging console?

           

          You must use "if' not "If" for the if control statement.

           

          The comparison operator for greater than is ">" and not "!=", not equal to.

           

          Have you tried to access the value of the field object and not the field object?

           

           

          // some debugging information
          //oepn the JavaScript debugging console:
          console.show();
          console.clear();
          var aant = this.getField("Aantal")
          console.println("typeof Aantal: " + typeof aant);
          console.println("value of Aantal: " + aant.value);
          console.println("typeof Aantal.value: " + typeof aant.value);
          // results of compartive operator test
          console.println("aant.value < 1:" + (aant.value < 1));
          console.println("aant.value <= 1:" + (aant.value < 1));
          console.println("aant.value == 1:" + (aant.value == 1));
          console.println("aant.value  != 1: " + (aant.value != 1) );
          console.println("aant.value > 1:" + (aant.value > 1));
          console.println("aant.value >= 1:" + (aant.value >= 1));

          if(aant != 1) {
          console.println("aant != 1");
          } else {
          console.println("aant != 1 not true");
          }

          if(aant.value != 1) {
          console.println("aant.value  != 1");
          } else {
          console.println("aant.value != 1 not true");
          }

          if(aant.value > 1) {
          console.println("aant.value  > 1");
          } else {
          console.println("aant.value > 1 not true");
          }
          // end debugging code

          If (aant != 1)
          {
          this.getField("Naam intro").setFocus();
          }