2 Replies Latest reply on Sep 21, 2009 6:46 AM by campy3

    Calculate this or that...any ideas?




      In my PDF files I have a calculation that takes the BSA and uses that to calculate the dose of a medication.  Most drugs have a recommended dose of mg/m2, but I want the option for this to be changed and still have the "normal dose" show up on the form.


      Is there a way to have a calculation script calculate the first field, OR calculate the second field if this is filled in.  If not, it will calculate the first field only.


      I attatched an example file.  It sounds easy, but I have no javascript experience.


      Thanks very much ahead of time

        • 1. Re: Calculate this or that...any ideas?
          gkaiseril MVP & Adobe Community Professional

          You have write a "Custom calculation script" for the field, you can not any of the simple calculation options and you should set numeric fields to the proper numeric format.


          So for the 'dosage1' field one could use:


          // field name for override
          var Field_Name = 'drug1';
          // default dosage rate
          var Drug_1_Dose_Rate = 85;
          // see if we need to override
          if (Number(this.getField(Field_Name).value) != 0) {
          // Drug1 field not empty so use the entered value
          Drug_1_Dose_Rate = Number(this.getField(Field_Name).value);
          } // end if not null
          // compute the dosage using the required rate
          event.value = Drug_1_Dose_Rate * this.getField('BSA').value;

          • 2. Re: Calculate this or that...any ideas?
            campy3 Level 1

            Thanks very much =).  That was a huge help.