8 Replies Latest reply on Feb 12, 2017 12:43 PM by try67

    Need help with this script. Take a look.

    pdfUser1 Level 1

      I'm using this script to generate a random number. It works fine but I would like to modify it to include a No, Cancel, Yes button. As you can see I figured out placing the "3" into the script gives me the three buttons. But, the random number still gets placed into the m12 field, regardless of what button is pressed. Can someone show me how to make the modification so I'll be able to have the choice as to what I want to do? Here's my existing script.


            case "ID Number":       

      // custom funcitons to generate random integers and random strings;

      function RandomInt(nMax, nMin) {

      // generate a random integer between the nMin and nMax values

      if(typeof nMin == "undefined") nMin = 0;

      nMin = parseInt(nMin);

      nMax = parseInt(nMax);

      return Math.floor(Math.random() * (nMax - nMin)) + nMin;

      } // end RandomInt function

      function RandomString(cValues, nLength) {

      // generate a random string of length nLength from string of cValues;

      nlength = parseInt(nLength);

      // convert string of values to an an array;

      var aValue = cValues.split("");

      // array for results of random characters;

      var aResult = new Array()

      // random intiger;

      var nRandom;

      // populate array with 6 random values;

      for(i = 0; i < nLength; i++) {

      // get random number;

      nRandom = RandomInt(aValue.length);

      // insert random letter into array;

      aResult[i] = aValue[nRandom];

      } // end of populate array;

      // convert array of values to a string;

      return aResult.join("");

      } //

      // end custom funcitons;


      // possible values for items in the field

      var cString = "ABCDEF0123456789";

      // generate a random string of values;

      var cResult = RandomString(cString, 7);

      // display the random string

      // populate a field with the value;

      app.alert("Enter unique Proposal Number:\n\n" + cResult, 0, 3);  ///this produces the No, Cancel, Yes buttons

      this.getField("m12").value = cResult;



      Thank you all for taking the time to read my post. If you can help, please do.