6 Replies Latest reply on May 3, 2011 9:02 AM by soonermike01

    I can't create a javascript saveas for radiobox


      I started this discussion in acrobat windows forum and I think I should have put it here so I'm reposting it.


      First, I want to say thanks for helping.


      I  am new to javascript and coding in general, but I feel that I have been  learning and picking up the coding from sites like this.  I am making a  form using adobe acrobat pro 3D 8.1.0.  I have a combobox that I have a  list of a bunch of locations.  The combobox is set to export a 3 or 4  letter or digit result that is unique to that site.  I have then set up a  saveas on blur following the selection.  This is all working correctly.


      However,  I several hundred radioboxes and textboxes in the document.  This  document will be used for acceptance testing and I do not want to  accidentally lose any data so I want to save after every selection or  input in the textboxes.


      The following is my code for the combobox.


      // build file name
      var site = this.getField("siteName").valueAsString;
      var dd = this.getDate();
      var mm=this.getMonth()+1;
      var yyyy=this.getFullYear();
      return String(mm+"-"+dd+"-"+yyyy)


      var today = new Date();
      var gmtHours = -today.getTimezoneOffset()/60;
      var cstHours = today.getUTCHours() + gmtHours;
      var min = today.getUTCMinutes();
      var sec=today.getUTCSeconds();
      var timeStamp=today.defaultView() + "_" + cstHours + "-" + min + "-" + sec;
      var myFileName = site + "_" + timeStamp + ".pdf";
      // add folder name
      myFileName = "/f/file_test/" + myFileName
      myTrustedSpecialTaskFunc(this, myFileName);


      this.getField("docName").value = myFileName;




      I  was struggling with the saveas and I don't want to create a new file  everytime so I created a hidden textbox that has the file name.  I was  hoping that I could just read this textbox and saveas using the original  filename.  (The script above uses time in the filename so that would  create a new file name every second)  The hidden text box is getting the  values correctly and is working fine.


      I have tried  several different methods of javascript on the radio buttons and text  text boxes.  On the radio button I have tried all mouse options, but I  was hoping to use mouse up.  The textboxes I want to use mouse, on  blur.   Below is some of the scripts that I have tried.  I want it to be  automatic and I want it to overwrite everytime without prompts.





      var oMyDoc = <… PDF being operated on …> app.execMenuItem("Save", oMyDoc);


      var myFileName = this.getField("docName").valueAsString;




      ....and I have tried others, but since they didn't work, I didn't keep track of them.


      I appreciate any suggestions!