I need help converting an excel formula to javascript for a fillable form.

Here is the scenario,
If a person travels for 1 or 2 days we pay out a mealsrate of 75% per day. If 3 or more days we pay # days less 2 days * 25%. I hope that makes sense.
V7 = Days, F14 = Mealsrate
Formula in Excel
=IF($V$7 = 1,$F$14*0.75,($V$7*$F$14)-(($F$14*0.25)*2))  and it works.
I am VERY NEW to javascript (like yesterday) so don't laugh. I really have no idea what I am doing, but I was trying. Here is what i got. (by the way, It doesn't work)
if(this.getField( ("Days").value=="1")){
var f =this.getField("Mealsrate");
event.value= f.value * .75;
}else event.value = (Days * f.value)- (f.value *.25)*2;
I appreciate all the help i can get.
Tracie
I'll be back on Monday, I hope I can find my post.

OK, that Excel formula can be reduced a bit. The following custom Calculate scipt will do what the formula does:
// Custom Calculate script
(function () {
    // Get the inputs
    var days = getField("Days").value;
    var rate = getField("Mealsrate").value;
    // Set this field value
    if (days == 1) {
        event.value = 0.75 * rate;
    } else {
        event.value = (days - 0.5) * rate;
It would make sense to add additional code to deal with negative numbers in either of the input fields.
Edit: corrected a typo

Similar Messages

  • I need help convert a 32 bit hex number to the following form

    is there a java class in the API that help me to do this?
    3e900000 ==> 2^-2(1 + 2^-3)

    okay, lets get technical.
            double d = 0.28125;
            // from BigDecimal(double)
            long valBits = Double.doubleToLongBits(d);
            int sign = ((valBits >> 63) == 0 ? 1 : -1);
            int exponent = (int) ((valBits >> 52) & 0x7ffL);
            long mantissa = (exponent == 0 ? (valBits & ((1L << 52) - 1)) << 1 : (valBits & ((1L << 52) - 1)) | (1L << 52));
            exponent -= 1023;
            System.out.println("sign=" + sign + ", exp=" + exponent + ", mantissa=" + Long.toBinaryString(mantissa));

  • Need help converting a PDF to excel

    Need help converting a PDF to excel, the icon to convert dissappeared suggestions?

    Open the file in Acrobat, use File --> Save As... --> Microsoft Word.
    Mylenium

  • I want to convert this excel formula into a formula that works in Numbers =INDEX(Codes!$B$1:$B$9998;MATCH(TRUE;ISNUMBER(SEARCH(Codes!$A$1:$A$9998;'Curren t Account'!E4358));0))

    I want to convert this excel formula into Numbers formula =INDEX(Codes!$B$1:$B$9998;MATCH(TRUE;ISNUMBER(SEARCH(Codes!$A$1:$A$9998;'Curren t Account'!E4358));0))

    Without knowing the structure of the spreadsheet, or what e3xactly you are trying to do, it would be hard to advise. however, have a look here: http://help.apple.com/numbers/ipad/2.0/

  • Need help converting from 4.0 to 2011

    hello,
    Need help converting files from 4.0 to 2011.
    thank you
    Solved!
    Go to Solution.
    Attachments:
    noise source.vi ‏73 KB
    8673D.vi ‏30 KB
    8970 FREQ.vi ‏26 KB

    attached as 8.2, which you can open
    missing some subVIs - not sure if you already have them
    Attachments:
    8673D.vi ‏13 KB
    8970 FREQ.vi ‏11 KB
    noise source.vi ‏24 KB

  • Excell Formulas to Javascript

    I just got a request to convert an Excel file to PDF, and make the form calculate.  The calculations are pretty complex (at least to me they are).  There are four different types of formulas needed.  I've copied the information below.  Can someone help me with writing the scripts for PDF that would accomplish what the Excel formulas do?  I don't even know if it's possible to do and where to start.
    Thanks
    Connie Bretes
    Break Date:
    =IF(A20>0,$A$3+D20," ")
    If there is a tag number entered for the corresponding row, the equation will take the date cast and add the number of days until it's break, and give the date of the break. If no tag number (or any form of ID)
    is entered into the tag number cell, a blank cell will be shown.
    Correction Factor (C.F.):
    =IF(N20>0,LOOKUP('Correction Factor'!A3,'Correction Factor'!$C$3:$C$104,'Correction Factor'!$D$3:$D$104)," ")
    If there is a number entered in the corresponding Total Load cell, the equation will look up the correction factor value from the list in the correction factor tab based on the length and diameter ratio calculated in column A in the Correction Factor Tab, and give the proper correction factor.  If no total load value is given, a blank cell will be shown.
    P.S.I.
    =IF(N20>0,ROUND(((N20/(3.1415926535*((L20/2)^2)))*M20),-1)," ")
    If there is a number entered in the corresponding Total Load cell, the equation will solve (total load) / (pi * (diameter / 2)^2) to get PSI, and then multiply by the corresponding Correction factor to give it the appropriate PSI value.  The round function then rounds it to the nearest 10 value.  If no total load value is given, a blank cell will be shown.
    Average:
    =IF(N20>0,ROUND(AVERAGE(O20:O21),-1)," ")
    If there is a number entered in the corresponding Total Load cell, the equation will average the values of the 2 breaks for the cylinders cast for that day and round to the nearest 10 value. If no load value is given, a blank cell will be shown.

    First there is no direct conversion from Excel formulas to Acrobat's JavaScript. You need to know that even the simplified field notation and the field selection for some calculations both use JavaScript behind the scenes to perform the calculation.
    There is no easy date calculation like in Excel in JavaScript, you need to write custom JavaScript to convert the date string to a date object and then convert the date object to a date unit value and perform your calculation and then convert the result back to the date object for conversion to a string value. The format of the date strings is very important for these conversions.
    You also need to be aware that JavaScript's use of the IEEE floating point standard for decimal numbers introduces an error when using JavaScript's Math.round method so you need to create rounding function. JavaScript's Math.round method only works for integers.
    You might want to start with the tutorials at the http://acrobatusers.com/tutorials
    or www.pdfscripting.com

  • I need help exporting Apple Mail messages to Outlook for MAC 2011

    Good morning,
    I need help exporting Apple Mail messages to Outlook for MAC 2011. Please....

    It is possible to do this without external tools, but it is a tremendous faff. See
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macoutlook/import-ema il-from-mail-to-outlook-2011/5e858173-e1f4-4adc-99d7-253cc467169d?page=2 for details.
    The easiest way, however, is to use Mail Exporter Pro https://itunes.apple.com/us/app/mail-exporter-pro/id675131616?mt=12 which will convert the email for you from one format to the other, and comes with an excellent manual.
    A third possibility is to connect Apple Mail to an email account via IMAP (this doesn’t have to be your usual account, you can just create a Gmail account for the purpose) . Copy all the messages into it and they will be uploaded. Then connect Outlook 2011 to the same account, via IMAP again, and let the messages download, then copy them to wherever you want to keep them and disconnect from that account. This is slow but preserves the attributes of your email (e.g. read/unead) better than any other method.

  • Need to convert 16X9 to 4:3 letterbox for DVD

    Hello
    Can anyone tell me the settings I need to convert 16X9 to 4:3 letterbox for DVD. I am mixing other 4:3 letterbox content. Evertime I make an mpeg with Quicktime conversion it is squeezed. I want it to be letterbox in 4:3
    Thanks in advance.
    I am using Final Cut Pro 4.5 and DVD pro 3
    Regards,
    Dana Gonzales

    In addition to using the advice above, make sure in Compressor (or other item you use to encode) that you are using the 16:9 encode ratio. If you are using QT conversion (which it sounds like from Final Cut?) also make sure that ratio is checked. Unlike a 4:3 m2v which will be 720 x 480 when you open it in QT, the 16:9 will be 720 x 404

  • HOW TO?: Need help setting up 3 different iCloud accounts for my kids (so each has own iMessanger)using same Apple ID (mine) ....they don't have their own separate email addresses to work from...how do I do this?

    Need help setting up 3 different iCloud accounts for my kids (so each has own iMessanger)using same Apple ID (mine) ....they don't have their own separate email addresses to work from...how do I do this?

    Any devices connected to the same icloud account can sync all the data on that account.  For this reason an icloud account is really for a single user.
    On a mac, if each user has their own account, then the itunes for that mac account should be set up to connect to that user's icloud account (System preferences>icloud).

  • Need help using WEB module in Lightroom 2 for .mac/mobile me accounts

    Hello,
    I need help in finding the Server path information for Lightroom 2.  I am trying to use the Web module of Lightroom and build a website and instead of going through another hosting service, I want to use my Mobile ME account, can't I do that?
    I have the user name and password obviously but what is the server path, protocol, path?
    Help please!
    Thanks
    Ray

    For those Mac Users using iWeb, MobileMe, and Lightroom 2, here are step-by-step instructions on how to create a web gallery in Lightroom, upload the gallery to MobileMe, and finally, how to link the uploaded files to the wesite you created in iWeb.
    1. In the Lightroom Library module, create a collection of photos you want to display in your web gallery.  For illustration purposes, we will call your collection Sunsets.  Once created, it will be listed under Collections in the left panel of Lightroom.
    2. Switch to the Lightroom Web module and select the Sunsets collection (from the panel on the left of the screen.)
    3. Chose whichever template you like (from the list of Templates in the left panel).
    4. Fine tune the appearance of the gallery using the controls in the right hand panel of Lightroom 2.
    5. When you are satisfied with the gallery’s appearance, use your keyboard to type Command-S.  That will save your template settings (give it a unique name when saving).
    6. Open up Finder on your Mac.  Inside your username folder, create a new folder… I'll call it Web Files.  (You can choose any name you like, and locate the file anywhere on your Mac HD.)  You have just created the folder username/Web Files.
    7. Back in the Lightroom Web module, chose Export, at the bottom of the right panel, and export your gallery to the folder you just made (e.g. export to username/Web Files).  By doing so, you will have created /username/Web Files/Sunsets.
    8. Once again open Finder on your Mac.  Go to /username/Web Files/Sunsets and you will see 3 files in the Sunsets folder: bin, index.html, and resources.
    9. Open a second Finder window and in it, click on your iDisk icon.  You will soon see all of the files on your iDisk.
    10. In iDisk, click on the folder called /Web.  You will now see the /Sites folder inside the /Web folder.  I.e., /Web/Sites.
    11. Drag the Sunsets file from your Mac HD to the /Sites folder on your iDisk.  E.g, drag Sunsets from /username/Web Files/Sunsets on your Mac HD to the /Sites folder in iDisk /Web/Sites.  The Sunsets folder (and the three files it contains) will now upload to your iDisk on MobileMe.
    12. Open iWeb on your Mac. Add a new page to your website.  Call it “Galleries,” or anything you like. (You can also use an existing page if you wish.)
    13.  On that “Galleries” web page (or on an existing web page), create a picture icon, or a word, or a symbol, or anything else that you will activate as a hyperlink to your iDisk web files - specifically, you will link it to the Sunsets folder you just uploaded to iDisk.
    14. Activate the hyperlink in iWeb’s Inspector.  In the URL box, type:
    http://web.me.com/username/Sunsets  (Don’t forget to substitute your name for “username” and the name of your gallery for “Sunsets.”)
    15. Save your website in iWeb, and then publish your site.
    You will NOT see your gallery in iWeb – you will see only the link to the gallery that you uploaded to iDisk..  To view your gallery, either make hyperlinks active, using the Inspector in iWeb and click on he link to the gallery, or visit your website on the internet.  If you want to edit your gallery, you will have to do that in Lightroom… then repeat steps 7 – 11.  You cannot edit your gallery in iWeb, but you can use iWeb to change the appearance of the link to your gallery, or to change it’s location within your website.

  • Hii i need help i cannot use my apple id for download on app store because they say i need to verify my account but i don't know how so please somebody can help me? i try to resset my password but that don't help

    hii i need help i cannot use my apple id for download on app store because they say i need to verify my account but i don't know how so please somebody can help me? i try to resset my password but that don't help

    is it asking for ur security questions?

  • Need help . Bought original HP 21b ink for F370 all in one printer , its not printing

    Hi , 
    Need help . Bought original HP 21b ink for F370 all in one printer , its not printing at all .Kindly mail at [Thank you for visiting the HP Support Forums. I am sorry to inform you that your post has needed some editing to remove personal information.]
    . Thanks .

    Hello @Bn23 , and welcome to the HP Forums, I hope you enjoy your experience!
    I see you're running into print issues.  I would love to try and help you, but I do need a little information first. I am linking a few HP Support documents below that will show you how to find which operating system you are using. Also, if you're using Windows, please include whether your operating system is 32-bit or 64-bit. With this information we can provide you with accurate information.
    Mac OS X: How Do I Find Which Mac OS X Version Is on My Computer?
    Which Windows operating system am I running?
    Is the Windows Version on My Computer 32-bit or 64-bit?
    Also, when you print, does a blank page come out, or does no paper feed through the printer?  Is there any errors that come up?
    Please let me know what you find.  Thanks for posting on the HP Forums!
    Please click “Accept as Solution " if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the right to say “Thanks" for helping!
    Jamieson
    I work on behalf of HP
    "Remember, I'm pulling for you, we're all in this together!" - Red Green.

  • Need help! Can't validate date overlaps for a tabular column

    Hello all,
    The validation I created to validate whether new or updates rows does not overlap with any records in the table isn't working.
    The columns are StartDt and EndDt
    Validation Type: NOT EXISTS
    Validation expresion:
    select 1
        from  sample S
        WHERE S.STARTDT BETWEEN :STARTDT AND :ENDDT
    OR(S.ENDDT BETWEEN :STARTDT AND :ENDDT)
    or (S.STARTDT <= :STARTDT and S.ENDDT >= :ENDDT)
    or (:STARTDT <= S.STARTDT and :ENDDT >= S.ENDDT)
    Error Message:
    Times overlap
    When Buttons pressed
    -Select Button-
    The validation works if a new row or updated row overlaps any existing start and end date records but it doesn't work if I update startdate and end date rows that doesn't overlap existing date times
    Example:
    TABLE DISPLAYS THE FOLLOWING RECORDS
    NAME                   START DATE                      END DATE
    TEST                    1/1/2012                               12/31/2012
    If I update the rows to the following values, I receive an error message (although those values don't overlap any records in the table)
    NAME                   START DATE                      END DATE
    TEST                    6/1/2012                               10/30/2012
    Any ideas? Do I need to change my code?
    Click the link to view the answer to this question. Need help! Can't validate date overlaps for a tabular column
    Message was edited by: CharlieMack

    Logic for date range overlap testing only requires two conditions in the WHERE clause:
    ORACLE-BASE - Overlapping Date Ranges
    WHERE S.STARTDT <= :ENDDT AND S.ENDDT >= :STARTDT -- TRUE for ranges that overlap
    It looks a little odd, but, if you scribble out a 'logic table', it makes sense.
    Condition
    A.start <= B.end
    A.end >= B.start
    A__A B--B
    true
    false
    A__B=A--B
    true
    true
    A__B==B__A
    true
    true
    B--A==B__A
    true
    true
    B--B A__A
    false
    true
    MK

  • Need help " Can't find a valid editor for this file extension" not sure why I am getting and this or what to do.

    also say explorer not reading SWF files and I have to reload them? Not sure what that is either,
    Thanks
    Jim

    Hi Nancy
    Trying to update my site got to make some changes.  Do you work on sites via remote? I am on Cloud.
    : Nancy O. 
    Sent: Monday, September 01, 2014 3:47 PM
    To: James Neidner
    Subject:  Need help " Can't find a valid editor for this file extension" not sure why I am getting and this or what to do.
    Need help " Can't find a valid editor for this file extension" not sure why I am getting and this or what to do.
    created by Nancy O. <https://forums.adobe.com/people/Nancy+O.>  in Dreamweaver support forum - View the full discussion <https://forums.adobe.com/message/6692200#6692200>

  • How to convert an Excel Formula to a Custom Calculation Script in a Adobe Acrobat 9 Form?

    Hello,
    I am not familiar whatsoever with Javascript and need some help in converting the following Excel Formula so that I can enter it into a Custom Calculation Script in a Adobe PDF Form. Here is the formula:
    =IF(E15<25.01,9.95,IF(E15<50.01,11.95,IF(E15<75.01,13.95,IF(E15<100.01,16.95,IF(E15<150.01 ,19.95,IF(E15<200.01,24.95,IF(E15>200.00,E15*0.125)))))))
    Where "E15" will be the text field named "Subtotal" on my Adobe PDF Form.
    Thank you for any help you can provide!

    Fortunately JavaScript has the 'switch' statement so nested if statements can be avoided.
    var E15 = this.getField("Subtotal").value;
    switch(true) {
    case (E15 < 25.01) :
    event.value = 9.95;
    break;
    case (E15 < 50.01) :
    event.value = 11.95;
    break;
    case (E15 < 75.01) :
    event.value = 13.95;13
    break;
    case (E15 < 100.01) :
    event.value = 16.95;
    break;
    case (E15 < 150.01) :
    event.value = 19.95;
    break;
    case (E15 < 200.01) :
    event.value = 24.95;
    break;
    case (E15 > 200) :
    event.value = E15 * 0.125;
    break;
    default:
    event.value = "";
    break;
    } // end switch;

Maybe you are looking for