5 Replies Latest reply on Jan 9, 2018 6:23 AM by try67

    How can I create a "plus" and "minus" buttons to increase or decrease the value of a calculated numeric field?


      Hi, I am a novice but have enough knowledge to have created several complex engineering calculation forms.


      Currently I have the following situation and need assistance:


      Field "volume required" = calculated based on user entry (other fields in the form)

      Field "depth" = calculated as:  "volume required" / ("area" *2.32), taking that number and assigning it a value based on the range it is in (using if...else if)

      Field "area" = user entered

      Field "volume" = calculated as: "depth" * "area"


      I want to add a "plus" and "minus" buttons on either side of the "depth" field which should allow users to increase/decrease the value of the "depth" field in increments of 0.33. I am assuming that once that i s done the "volume" field will update based on the now changed value of "depth".


      I know how to create the buttons. I cannot seem to be able to come up with the script to get the buttons to manipulate the value of "depth". I created a hidden field which calculates the initial value for the depth and copied that value to the field that is visible on the form. I am trying to manipulate the visible field. The "volume" field is calculated based on the visible field.


      I have this so far, but  it is not working, nor it is giving me an error. This is the script for the "plus" button to be executed "On Mouse Up".


      (function () { 


          var RDP = this.getField("RS3DEPTHRow1").value;    // this is the "depth" - visible field which duplicates the value of RS3DEPTHRow1H (the hidden field)

          var UDP = RDP / 0.33;    // determining the range of the values

          var ADD1 = RDP + 0.32;    //some value ranges need to be increased by 0.32

          var ADD2 = RDP + 0.33;    //the rest of the ranges need to be increased by 0.33


          if  (UDP > 1 && UDP <= 2)  { 

              event.value = setField("RS3DEPTHRow1").valueAsString=='' ? '' : ADD1; 

          } else if (UDP > 6 && UD <= 7)  { 

              event.value = setField("RS3DEPTHRow1").valueAsString=='' ? '' : ADD1; 

          } else if (UDP > 11 && UDP <= 12)  { 

              event.value = setField("RS3DEPTHRow1").valueAsString=='' ? '' : ADD1; 

          } else  {  

              event.value = setField("RS3DEPTHRow1").valueAsString=='' ? '' : ADD2; 





      I am assuming that once I have this resolved, I can apply the same code and change it to subtract for the "minus" button.


      Is this even possible since I am trying to change the value of a calculated, read-only field?


      Thank you in advance!