Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Excel fomula conversion for PDF form

    Hello everyone,
    'recently converted an excel timesheet to a PDF form. Trying to get some help to convert two excel formulas (formulae?) into javascript.
    First Excel formula is intended to return the value of "40" if the total is above 40, otherwise display actual value: =IF(L17>40, 40,L17)
    Second excel formula is the "overtime" field, which displays the number of hrs above 40hrs, or displays "N/A" if below 40: =IF(L17>40, L17-40, "N/A")
    I have essentially no experience in Javascript and I am trying to learn, but any help to get me over this hump will be appreciated.
    Regards
    tim

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    IF(L17>40, 40,L17)
    becomes
    if (L17 > 40) {L17 = 40} // if not L17 retains its existing value;


    IF(L17>40, L17-40, "N/A")
    becomes
    if (L17 > 40) {L17 = L17-40}
    else {L17 = "N/A"}


    Quizmaster: In which century was Coca Cola invented?
    Contestant: The eighteenth

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    Tim R (03-09-2012)

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hello Philip,
    Thank you so much for the quick reply. I realized that I missed an important piece of information in my summary. In my excel file, the value which is subjected to the first formula comes from cell L17, but the result is displayed in cell G20. Similarly, the result for formula 2 is displayed in cell G21.
    With this in mind I believe I would need to put the javascript code in the equivalent "target" field of the PDF, but when I do that, nothing seems to happen when I simulate data entry. Do I need to somehow reference the target field in the code, where the resultant value will be displayed?
    Thanks again for any insight
    regards
    tim


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •