8 Replies Latest reply on Apr 12, 2016 4:51 AM by try67

    valueAsString

    klothos

      Hello

      I am using this code

      if (this.getField("Textfield69").valueAsString!="" && Number(this.getField("Textfield69").value) >= 1&&<=8) {

          event.value  ="1";

          event.target.display = display.visible;

      } else {

          event.value = "";

          event.target.display = display.hidden;

      }

      what am i doing wrong?

       

      javaScript Debugger          SyntaxError:invalid XML name 1:

        • 1. Re: valueAsString
          try67 MVP & Adobe Community Professional

          This part is incorrect:

          Number(this.getField("Textfield69").value) >= 1&&<=8

          You need to write out each condition in the if-statement in whole, like this:

          Number(this.getField("Textfield69").value) >= 1 && Number(this.getField("Textfield69").value) <=8

          • 2. Re: valueAsString
            klothos Level 1

            ok thanks and what about this

            if (this.getField("Textfield51").valueAsString!="" && Number(this.getField("Textfield51").value) = 1) {

                event.value = "1";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

            if (this.getField("Textfield57").valueAsString!="" && Number(this.getField("Textfield57").value) = 1) {

                event.value = "1";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

            if (this.getField("Textfield69").valueAsString!="" && Number(this.getField("Textfield69").value) >= 0&& Number(this.getField("Textfield69").value) <=8) {

                event.value  ="01";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

            if (this.getField("Textfield81").valueAsString!="" && Number(this.getField("Textfield81").value) >= 0&& Number(this.getField("Textfield81").value) <=8) {

                event.value  ="01";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

            if (this.getField("Textfield104").valueAsString!="" && Number(this.getField("Textfield104").value) >= 0&& Number(this.getField("Textfield104").value) <=1) {

                event.value  ="01";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

            if (this.getField("Textfield110").valueAsString!="" && Number(this.getField("Textfield110").value) = 1) {

                event.value = "1";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

            if (this.getField("Textfield116").valueAsString!="" && Number(this.getField("Textfield116").value) = 1) {

                event.value = "1";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

            if (this.getField("Textfield122").valueAsString!="" && Number(this.getField("Textfield122").value) = 1) {

                event.value = "1";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

            if (this.getField("Textfield104").valueAsString!="" && Number(this.getField("Textfield104").value) >= 1&& Number(this.getField("Textfield104").value) <=6) {

                event.value  ="01";

                event.target.display = display.visible;

            } else {

                event.value = "";

                event.target.display = display.hidden;

            }

             

            Acrobat JavaScript Debugger Functions Version 10.0

            Acrobat EScript Built-in Functions Version 10.0

            Acrobat SOAP 10.0

             

             

            SyntaxError: invalid XML name

            1:

            SyntaxError: invalid XML name

            1:

            SyntaxError: invalid XML name

            1:

            SyntaxError: invalid XML name

            1:

            SyntaxError: invalid assignment left-hand side

            1:

            SyntaxError: invalid assignment left-hand side

            1:

            • 3. Re: valueAsString
              try67 MVP & Adobe Community Professional

              You should really spend some time studying the code JavaScript syntax. It will help you solve many of these problems on your own...

               

              The problem now is that you're using the assignment operator ("=") instead of the comparison operator ("==") in some of your if-statements.

              • 4. Re: valueAsString
                klothos Level 1

                can you please locate one if -statement to the above code using ("=="),just to start

                Thanks

                • 5. Re: valueAsString
                  try67 MVP & Adobe Community Professional

                  The first one. And the problem is it's *not* using "=="...

                  • 6. Re: valueAsString
                    klothos Level 1

                    ok this the new one

                    if (this.getField("Textfield51").valueAsString!="" && Number(this.getField("Textfield51").value) ==" 1") {

                        event.value = "01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden; 

                    }if (this.getField("Textfield57").valueAsString!="" && Number(this.getField("Textfield57").value) ==" 1") {

                        event.value = "01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden;

                    }if (this.getField("Textfield69").valueAsString!="" && Number(this.getField("Textfield69").value) >= 0&& Number(this.getField("Textfield69").value)  <=8) {

                        event.value  ="01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden;

                    }if (this.getField("Textfield81").valueAsString!="" && Number(this.getField("Textfield81").value) >= 0&& Number(this.getField("Textfield81").value)  <=8) {

                        event.value  ="01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden;

                    }if (this.getField("Textfield104").valueAsString!="" && Number(this.getField("Textfield104").value) >= 0&& Number(this.getField("Textfield104").value)  <=1) {

                        event.value  ="01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden;

                    }if (this.getField("Textfield110").valueAsString!="" && Number(this.getField("Textfield110").value) ==" 1") {

                        event.value = "01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden;

                    }if (this.getField("Textfield116").valueAsString!="" && Number(this.getField("Textfield116").value) ==" 1") {

                        event.value = "01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden;

                    }

                    if (this.getField("Textfield128").valueAsString!="" && Number(this.getField("Textfield128").value) >= 1&& Number(this.getField("Textfield128").value)  <=6) {

                        event.value  ="01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden;

                    }if (this.getField("Textfield122").valueAsString!="" && Number(this.getField("Textfield122").value) ==" 1"&& Number(this.getField("Textfield122").value)  =="3") {

                        event.value  ="01";

                        event.target.display = display.visible;

                    } else {

                        event.value = "";

                        event.target.display = display.hidden;

                    }

                    everything is ok exept the last if statement.I am so close to finish

                    • 7. Re: valueAsString
                      try67 MVP & Adobe Community Professional

                      If you use the Number constructor then you should compare to numbers, not

                      strings.