1 Reply Latest reply on Apr 18, 2015 1:38 PM by try67

    Acrobat javascipt problem with text field

    Onsightclimb Level 1

      Hello.

      I work in hospital and I create a PDF with some javascript, to help us working with our patients. This PDF now need some upgrade and I m stuck. Im not a programmer, so its even more difficult to me.

      Let me describe my problem. I have three buttons in my PDF with this code: on mouse up run javascript (I replace actual names in menu with options)

      //

      var cChoice = app.popUpMenuEx

      (

         {cName: "Option1", oSubMenu:

            [ { cName: "A", cReturn: "A" },

              { cName: "B", cReturn: "B"},

              { cName: "C", cReturn: "C" }

            ]

         },

         {cName: "Option2", oSubMenu:

            [ { cName: "D", cReturn: "D" },

              { cName: "E", cReturn: "E" },

              { cName: "F", cReturn: "F" }

            ]

          }

      );

       

       

      if(cChoice != "" && cChoice != null)

      {

      this.SetFieldValues(cChoice);

       

      }

      else if(cChoice != null)

      {

                   this.print({bUI:true,bSilent:false});

      }

      //

       

      I also have four text fields in PDF, fields "d1", "d2", "d3" and field "kat".
      Inside document javascript I have setFieldValues script:

       

      // Place all pre-population data into a single data structure

      var DeptData = { "":{  diagnoza: "", kat: "" },

      "A":{ diagnoza: "A", kat: "KAT III" },

      "B":{ diagnoza: "B", kat: "KAT II" },

      "C":{ diagnoza: "C", kat: "KAT I" },

      "D":{ diagnoza: "D", kat: "KAT III" },

      "E":{ diagnoza: "E", kat: "KAT II" },

      "F":{ diagnoza: "F", kat: "KAT I"}};

       

      function SetFieldValues(cDeptName) {

          // Populate fields with values from the Department Data Object

          this.getField("d1").value = DeptData[cDeptName].diagnoza;

          this.getField("kat").value = DeptData[cDeptName].kat;

      }

      function SetField1Values(cDeptName) {

          // Populate fields with values from the Department Data Object

          this.getField("d2").value = DeptData[cDeptName].diagnoza;

          this.getField("kat").value = DeptData[cDeptName].kat;

      }

      function SetField2Values(cDeptName) {

          // Populate fields with values from the Department Data Object

          this.getField("d3").value = DeptData[cDeptName].diagnoza;

          this.getField("kat").value = DeptData[cDeptName].kat;

      }

      //

       

      Now my problem. This code work perfect for my d1, d2, and d3 fields. When nurse click first button and open menu, then select options, the value that she select print in field d1, value from second button print in d2 and value from last button in d3. But each selection has also second value, named "kat". This value must be printed in text field named "kat", but...here is some catch. If all three selected options have different "kat" values - all three values must be in text field "kat". If one or two values are equal, I need that just one of them is printed.

      Something like that:

      If

      "d1" field has "A" value

      "d2" field has "B" value

      and "d3" has "C" value

      then field "kat" has all three kat values.

       

      but if

      "d1" field has "A" value

      "d2" field has "D" value

      and "d3" field has "E" value

      then field "kat" print only one of two equal (A and B) kat values and E kat value, that is different.

       

      Anyone understand my bad english and my problem and has a solution for this?