4 Replies Latest reply on Sep 15, 2012 12:58 PM by hinckdogg

    Reset form script error

    hinckdogg

      When I try to run the following code in my Reset button, I get a "missing ) after argument list 3: at line 4" error message. I've tried lots of different things, but I can't figure out what's wrong.

       

      // --- Start of code ---

      // set field's defaultValue to the value of the field

      this.getField(1 Date).defaultValue = this.getField(1 Date).value = util.printd("mm/dd/yyyy", newDate());

      this.getField(3 NC No).defaultValue = this.getField(3 NC No).value = (newDate()).getTime().toString()

      // confirm reset operation

      if (app.alert("Do you really want to clear all fields of this form?", 2, 1) == 1)

      this.resetForm(); // reset all form fields to default values

      // --- End of code ---

        • 1. Re: Reset form script error
          try67 MVP & Adobe Community Professional

          Field names are strings and therefore must be enclosed in double-quotes.

           

          Also, the way you use the assignment operator (a = b = c) is not recommended.

          You should split these lines like so: a = b; c = b; or a = c; b = c; or whatever it is you're trying to achieve...

          • 2. Re: Reset form script error
            hinckdogg Level 1

            Is this better?

             

            // --- Start of code ---

            // set field's defaultValue to the value of the field

            this.getField("1 Date").value = util.printd("mm/dd/yyyy", new Date());

            this.getField("1 Date").defaultValue = this.getField("1 Date").value;

             

            this.getField("3 NC No").value = new Date().getTime().toString();

            this.getField("3 NC No").defaultValue = this.getField("3 NC No").value;

             

            // confirm reset operation

            if (app.alert("Do you really want to clear all fields of this form?", 2, 1) == 1)

            this.resetForm(); // reset all form fields to default values

            // --- End of code ---

            • 3. Re: Reset form script error
              try67 MVP & Adobe Community Professional

              As far as syntax goes, yes. If it does what you want it to do is another

              question...

              • 4. Re: Reset form script error
                hinckdogg Level 1

                It appears to be working as desired. Thank you for your help try67.