No announcement yet.

Custom Javascript if/else

  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Javascript if/else


    I have a PDF that I am creating where I need some calculations done.

    I have a bunch of fields that are fillable and they are being used elsewhere in the document.

    One of the final fields is the calculation is if the value is below a certain amount then it has to be a minimum amount, else it is the already calculated value.

    The javascript that I am using is as follows:

    var Sub_TotalCalc=Sub_Total
    if (Sub_TotalCalc < 600) {
    Total_Premium = 600
    } else {
    Total_Premium = Sub_Total

    Now I have run this through a console and it returns everything correctly, if the variable Sub_Total is less than 600 it makes Total_Premium 600. If it's greater, Total_Premium is the value of Sub_Total.

    All the fields are formatted as numbers.

    I have tried adding this into the section under calculate tab Simplified Field Notation and Custom Script field and neither have done anything. I have also tried creating a hidden field where the calculation is done and the Total_Premium field is set to "Is the Product of (x) and used that hidden field.

    I have also tried creating a button where when it's pressed it runs that Javascript.

    I'm at a loss as to why this isn't working. It's a very basic Javascript that should work. What am I missing, is there a setting I need to change?


  • #2

    Anybody? Foxit Staff...any suggestions?


    • #3
      Dear AsternMadkatz,

      Thanks for post.Please help to send us the PDF file sample with the Custom Javascript that you mentioned for us to take a closer look at first ,so that we can further advise.
      Please help to email it to (Attn:Lisa). And indicate this thread link. Thank you.


      • #4
        Thanks, Sent email.