8 Replies Latest reply on Nov 29, 2017 12:17 PM by Thom Parker

    Create a button that runs javascript in a text field

    griffona84090832

      Hi,

       

      I'm extremely new to this and need some help. I have created a form that has a script to generate a purchase order number (date, time, etc.) but unless the user actually clicks in the field or tabs across it, the action does not complete. So if there is a way for the number to auto-populate upon saving the document, I figured my only way was to create a button (Create P0#) that the requestor or manager can create upon the button press.

       

       

      Text field = workOrderNumber

       

      JavaScript =

      var f = this.getField("workOrderNumber");
      var d = new Date();
      var df = util.printd("mmddyyyy-HH-MM-", d)

      if (f.value == "") {
          f.value = df + Math.round(Math.random() * Math.pow(2, 5));
      }

       

      Any advice would be greatly appreciated.

       

      Thanks,
      Will

       

      (Using Adobe Acrobat Pro DC)