Conversion of a type formula Excel based in JavaScript

I have an auto fill table in an Acrobat document. understood most of the equations simple but I have a slightly more complicated that requires JavaScript and I know that nada.

The player entered two values (a), (b).

and if I were writing the fomula in Excel, I would write:

= a-(IF (b < 20,5 20,5, b)) + 41.5

Any thoughts on how to translate this?  Thank you!

If you want it to be a custom calculation for a field script, it could be:

Custom text field calculation script

(function () {}

Get the field values as numbers

var a = + getField("A").value;

var b = + getField("B").value;

Set the value of this field

Event.Value = a - (b).< 20.5="" b="" :="" 20.5)="" +="">

})();

but replace 'A' and 'B' in the statements of getField with the names of actual field that you are using.

Tags: Acrobat

Similar Questions

  • Conversion of PDFs to word, excel etc. - subscriptions are not yet supported in my country. What should do?

    Conversion of PDFs to word, excel etc. - subscriptions are not yet supported in my country. What should do?

    You can buy and older Acrobat who uses a serial number that Creative Cloud now includes Creative Suite Master Collection and Design Premium features

  • "Truncate" formula Excel in JavaScript

    I'm translating a formula Excel in Java script and I'm way out of my depth... If someone could help?

    It's the formula in Excel: = TRUNC ((*(A2/100) B2) / 365,2)

    In my Adobe Pro Document B2 is a field called 'RAD' and A2 is a field called ' MPIR '.»


    I want to translate the formula truncated to JavaScript so that my calculation of field 'DAP_ONLY' in Adobe Pro rounds not upward (as seems to be the default setting)

    For the moment, I have simplified notation field according to the value (RAD *(MPIR/100)) / 365 for my domain "DAP_ONLY" and the number format, 2 decimal places. That works if I want the result to round but in I need in fact the result is truncated instead.


    I read material on the math.trunc in JavaScript function but do not know how to apply it because I don't speak JavaScript...  Is this something you can help with that?

    Thank you!

    Math.floor method is not equivalent to the TRUNC function. It's for positive values, but for negative values, you must use Math.ceil. Here's what might look like the script:

    Custom calculation script

    (function () {}

    Get the values of the field as numbers

    var RAD = + getField("RAD").value;

    var MPIR = + getField("MPIR").value;

    Perform the calculation

    var result = RAD * MPIR / 100 / 365;

    Truncate the result to two decimal places

    If (result > = 0) {}

    Event.Value = Math.floor(result * 100) / 100;

    } else {}

    Event.Value = Math.ceil(result * 100) / 100;

    }

    })();

  • I need a conversion formula excel in javascript for a form to fill out.

    Here's the scenario,

    If a person moves for 1 or 2 days pay us a mealsrate of 75% per day. If 3 days or more we pay # days 2 days * 25%. I hope that makes sense.

    Days, F14 = Mealsrate = v7

    Formula in Excel

    = IF ($V$ 7 = 1, $F$14 *,($V$7*$F$14)-(($F$14*0.25) 0.75 * 2)) and it works.

    I am VERY NEW to javascript (like yesterday) in order not to laugh. I have really no idea what I'm doing, but I tried. Here's what I got. (by the way, it does not work)

    If (this.getField (("Days").) Value == '1')) {}

    var f = this.getField ("Mealsrate");

    F.value = Event.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 Monday, I hope I can find my post.

    OK, this Excel formula can reduce a little. The scipt to calculate custom next going to do with the formula:

    // 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 be good idea to add additional code to deal with negative numbers in the two fields.

    Edit: fixed a fault

  • How to know which formula excel could not be converted to numbers?

    Hey guys,.

    3.6.2 numbers I used to open an EXCEL spreadsheet that uses a few different formulas.

    When you open the xlsx file, it tells me that failure to support formulas were replaced last calculated values.

    I have totally accept that, but is it possible to know, formulas THAT had to be replaced?

    Best regards

    Often, you will see a blue triangle in the upper left corner of the cells that have formulas not supported.  When you click the blue triangle, you should see a message like this:

    SG

  • Formula 'IF' Excel converted to Javascript

    Dear Forum

    I need to convert an editable PDF form Excel form.

    How this Excel formula converts in JavaScript:

    = IF (OR (D44 > F34;)) E44 > F12); "This text is displayed. « "; » »)

    Best regards, Mikko

    Assuming you want it's a custom calculation script, you can use the following text:

    Custom calculation script

    (function () {}

    Get the field values as numbers

    var D44 = + getField("D44").value;

    var F34 = + getField("F34").value;

    var E44 = + getField("E44").value;

    var F12 = + getField("F12").value;

    Set the value of this field

    Event.Value = D44 > F34 | E44 > F12? "This text will appear:";"

    })();

    but use real field names in declarations of getField. This assumes that the fields of entries have a digital format.

  • Formula Excel in the Script?

    = + F2 * 1.1 * G2

    Column (F2) is called Gross (header)

    1.1 is the multiplier of the brute

    G2 is where the customer fills the %

    He is so gross multiplied by 1.1 times the %

    ALL NEW here

    in your result field properties, you must first set to read-only.  Then go to the tab to calculate.  In the first box, you can create simple calculation of formulas by selecting the fields you want to be multiplied toghether.  To do this, you will need to create a field multiplier of 1.1% to the static address if you want to be able to select in the list.

    In the case that you do not want the multiply to show on your form, you can use the second box where you enter the calculation in simple notation.  Please note that the name of your fields have no '. ' to do.  The simple rating would be a little like excel: field * field * 1.1

    The last resort is the third area where you are free to use the code you like to more complicated calculations.  I think that your OK with either of the other two options.

  • Change the type of region based on the value of the element

    Hi all
    Is it possible to change a type of model of a region based on the value of the page element?
    For example, if I have a template type for the area has as the type of model and the region to hide/show for area B as hide/show as well.

    I want that type of region B model will be replaced by a type of custom template based on the value of an element in A region.
    Is this possible?

    Enjoy your entries.

    Thank you!

    Spriya wrote:
    Hi all
    Is it possible to change a type of model of a region based on the value of the page element?
    For example, if I have a template type for the area has as the type of model and the region to hide/show for area B as hide/show as well.

    I want that type of region B model will be replaced by a type of custom template based on the value of an element in A region.
    Is this possible?

    N ° you either need to have 2 instances of region B, based on different models and make one of them conditionally based on the value of the area A; or to develop a unique model with a structure that is flexible enough to be used in both cases and change its appearance and behavior, for example, Exchange classes in dynamic Action.

  • BSO Member conversion to ASO MDX formula

    Hi guys,.

    I am trying to convert the following Member BSO formula to ASO.

    FORMULA MEMBER BSO
    --------------------------------
    IF (@ISLEV ('TP', 0))
    @SUMRANGE ("TDI"->"feat"-> "ETC."->"PC NA Exch"->"", @ILSIBLINGS (@CURRMBR ("TP")));
    ELSE IF (@ISLEV ("TP", 1))
    "TDI"->"feat"-> "ETC."->"PC NA '->' Exch ';
    ENDIF;

    Conversion of the ASO
    ----------------------
    CASE
    WHEN
    IsLevel ([TP], 0)
    Sum (Sum (CrossJoin ({[TDI], [exploit], [ETC.], [PC NA], [Exch]}) THEN))
    MemberRange (([TP]. CurrentMember). FirstSibling, [TP]. Lag (1))
    )
    ON THE OTHER
    WHEN IsLevel ([TP], 1) THEN
    [TDI], [exploit], [ETC.], [NA PC], [Exch]
    )

    Can someone please help me with this? I came with the converstion above but it is not through.

    Thank you
    Mickael

    You have ADI, Feat, etc, PC NA, Exch wrapped in parens? (TDI, Feat, etc, PC NA, Exch)? You can also add .currentmember on behalf of each Member

    ([TDI].currentmember,[Feat].currentmember,[ETC].currentmember, [PC NA].currentmember, [Exch].currentmember) 
    
  • Download Excel-based Macbook Pro Version 10.10.5

    Hi, I have not mastered the numbers and want to download basic excel for graphics.  I have the Macbook Pro OS X version Yosemite and are looking for the easiest and cheapest option. I don't need all of microsoft office. What is an option? All the tips are greatly appreciated.

    It is not available as a stand-alone product outside Microsoft Office Excel for Mac. You can buy a stand-alone copy of MS Office, or subscribe to Office 365. There is also a free limited version of Excel available as a web application.

  • during the conversion of several Word and Excel docs in a combined PDF file random pages have blue background in the final PDF file.

    I have a user using Acrobat 10. It has been installed two weeks ago and had no problems at the start. Today, she said that when she tried to convert several word and excel docs by selecting and right-click on it to select convert/combine PDF format, pages randomly in the finished PDF file have a blue background. I did some research online and you can't find any information on this problem. Can anyone here shed some light on this subject and maybe point me in the direction of a solution? Any help is appreciated. Thank you!

    Hi Gilad,

    So something I didn't consider was that it could be a setting in office documents. The reason why I do not consider this was cause we tested several docs and had similar results each time. I returned and examined this possibility and found a setting in word that was causing this problem. Although the word doc showed no color page when opened in word, if I went to the "Page Layout"-> 'Color of Page', a shade of blue was chosen. By selecting "no color", then convert / combining documentation in PDF format, we have achieved the desired result. Thanks again for your response!

  • conversion of data types

    Hello

    How to convert date data type number data type:

    Using to_char and to_number

    Thank you

    Published by: josh1612 on November 17, 2008 12:37 AM

    What are your needs. What is your output of input and expected.

    Without that no one can give you the right solution. And why you want to convert first date in number?

    Somehow here is an example.

    SQL> create table t(dt date)
      2  /
    
    Table created.
    
    SQL> insert into t values(sysdate)
      2  /
    
    1 row created.
    
    SQL> select * from t
      2  /
    
    DT
    ---------
    17-NOV-08
    
    SQL> select to_char(dt,'ddmmyyyy') from t
      2  /
    
    TO_CHAR(
    --------
    17112008
    
    SQL> select to_number(to_char(dt,'ddmmyyyy')) from t
      2  /
    
    TO_NUMBER(TO_CHAR(DT,'DDMMYYYY'))
    ---------------------------------
                             17112008
    
  • Conversion from data type "float".

    In a wireless data logger I collect analog data with a 8-bit microcontroller and sending it as a UDP datagram. The data received in the LV application looks like this:

    \r\n020.43\s002.14\s000.00\s000.02\s ("------" "" display codes)

    0D0A 3032 302F 3433 2030 3032 2E31 3420 3030 3030 2030 3030 2E30 3220 (display Hex) 302F

    020.43 002.14 000.02 000.00 (normal display)

    I want to undress and show values 20.43, 2.14,0.0 and 0.02 in my application of LV.  Try with "Scan of the String" and "Decimal number to the string" but without much success. Maybe I can 'building' my data of the hexagon?

    Any idea is welcome. Thank you.

    Channel scan works very well for me.

  • How to create a type of "alarm" based on data time and acquired sensor system?

    Hi all

    I am relatively new to LabVIEW and have managed to create a VI that reads the data from the sensors voltage.  Each sensor outputs 2 voltage values and I treat these values in the form of 2 different values DBL.  I would like to be able to record each value of voltage as a base and then compare the readings of subsequent data with this base.  Once the base is fixed, I want a sort of "variable", defined as 'TIME' to be registered at the time the base voltage is recorded.

    The alarm should take place (or whatever it is Boolean TRUE value, I guess) once the tension to know remains within certain limits for about 2 hours.  I know that I can compare the time system w / 'TIME' that the base voltage value has been saved.  If pressure readings are beyond these limits, I would like the value of base zero voltage and the time PERIOD corresponding system again.

    I apologize in advance if this didn't ' describes my problem, but if someone could help me understand the best way to create this code, I would appreciate it a lot!

    Thank you!


  • Create the Excel using Indesign javascript file

    Hi all

    We can create csv file using indesign javascript. Is there a way to create excel file using indesign javascript?

    Thanks in advance

    Hi all

    It is a way to generate an Excel from an InDesign table by using a combination of jsx, vbs and applescript.

    Quite a long discussion on that Open with below is a better application of the suggestions here.

    // Exports SIMPLE tables to proper excel file single and double quotes in the table would have to be escaped on the Mac version
    // Does not take Unicode file names
    // with a bit of brain racking can be developed to deal with merged cells and nested tables
    // Pieced together by Trevor (wwww.creative-scripts.com coming soonish) based on the referenced sources
    // Sold AS IS https://forums.adobe.com/thread/1718021
    
    var doc = app.properties.activeDocument && app.activeDocument,
           myTable = myTable || getTable (doc);
    if (!myTable) {alert ("Take a break, needs a document with a table in it!"); exit();};
    var filePath = new File (Folder.temp + "/" + +new Date + ".xlsx"),
        osFilePath = filePath.fsName;
    if ($.os[0] === "M")  osFilePath =  osFilePath.replace(/(.)(\/)/g,"$1:").replace(/\//, "");
    
    exportTable (myTable, osFilePath);
    if (confirm ("Open new excel file")) filePath.execute(false);
     exit()
    function exportTable (myTable, filePath)
        {
            var  numberOfRows = myTable.rows.length,
                   rowNumber, columnNumber,
                   isMac = $.os[0] === "M",
                   rowContents = [],
                   setRange, openMark, closeMark;
    
            if (isMac)
                {
                    setRange = 'set value of range "A';
                    openMark = '" to {';
                    closeMark = '}';
                }
            else
                {
                    setRange = 'app.Range("A';
                    openMark = '") = Array(';
                    closeMark = ')';
                }
    
    for (var z = 0, rowNumber = 0; rowNumber < numberOfRows; rowNumber++) {
        var  numberOfColumns = myTable.rows[rowNumber].columns.length,
                toRange = GetExcelColumnName (numberOfColumns - 1),
                columnContents = [];
         for (columnNumber = 0; columnNumber < numberOfColumns; columnNumber++) {
             var cellContents = myTable.rows[rowNumber].cells.everyItem().contents;
             columnContents  = '"' + cellContents.join('", "') + '"';
         }
        rowContents[rowNumber] = setRange + ++z  + ":"  + toRange+ z + openMark  + columnContents + closeMark;
    }
    
    var tableData = rowContents.join("\n") + "\n";
    
                   if (isMac)
                        {
                            // Thanks Hans https://forums.adobe.com/message/5607799#5607799
                           var myAppleScript =
                            '''set excelRunning to isRunning("Microsoft Excel")
                               tell application "Microsoft Excel"
                               set theWorkbook to make new workbook
                               tell sheet (1) of theWorkbook'''
                               + tableData + '''
                               end tell
                               save workbook as theWorkbook filename "''' + filePath + '''"
                               close active workbook
                               if not excelRunning then tell application "Microsoft Excel" to quit
                               end tell
                               on isRunning(appName)
                                    tell application "System Events" to (name of processes) contains appName
                               end isRunning
                            ''';
                          app.doScript (myAppleScript, ScriptLanguage.APPLESCRIPT_LANGUAGE);
                        }
    
                    else
                        {
                            // Thanks Calos https://forums.adobe.com/message/5607799#5607799
                            // changed by me :-)
                             var vbscript =
                             '''Dim app
                                Set app = CreateObject("Excel.Application")
                                'take away the ' from the line below if you want to see excel do it's stuff
                                'app.visible = true
                                Dim newDoc, sheet
                                Set newDoc = app.Workbooks.Add()
                                Set sheet = newDoc.Worksheets(1)
                                '''
                                + tableData
                                + 'newDoc.SaveAs "' + filePath + '''"
                                app.Quit
                                Set newDoc = nothing
                                Set app = nothing
                              ''';
                            app.doScript (vbscript, ScriptLanguage.VISUAL_BASIC);
                        }
    
                }
    
    function GetExcelColumnName (columnNumber) {// 0 is A 25 is Z 26 is AA etc.
        // parsed from http://stackoverflow.com/questions/181596/how-to-convert-a-column-number-eg-127-into-an-excel-column-eg-aa
         var dividend = columnNumber + 1,
                columnName = "",
                modulo;
    
        while (dividend > 0)  {
            modulo = (dividend - 1) % 26;
            columnName = String.fromCharCode (65 + modulo) + columnName;
            dividend = Math.floor((dividend - modulo) / 26);
        }
        return columnName;
    }
    
    function getTable (doc) { // thanks Marc http://forums.adobe.com/message/6087322#6087322
        if (!doc) return false;
        app.findTextPreferences = null;
        app.findTextPreferences.findWhat = "\x16";
        var tables = doc.findText();
        if (tables.length) return tables[0].parentStory.tables[0];
        return false;
    };
    

Maybe you are looking for