Custom calculation - multiple if statements

Hi guys

I'm stuck with a simple If statement. New to JavaScript.

I have a text field, drop-down "Gender" field "field" and the text field 'risk '.

In the 'risk' text field, I need to have a custom calculation script to know if 'Male' > = 45 or female > = 55, risk + 1.

I currently have the use of this:

Event.Value = "";

var a = + this.getField ("Age") .value

var b = this.getField ("Gender") .value +


If (a > = 45 & & b = "Male") event. Value = '+ 1'

ElseIf (a< = 45 & & b = "Male") event. Value = '0'

If (a > = 55 & & b = 'Female') event. Value = '+ 1'

ElseIf (a< = 55 & & b = 'Female') event. Value = '0'

Any help will be appreciated.

I notice another error. You are attempting to convert the value of sex together with the sign, even if it is not. This generates an error and prevents your working code.

Here is the fixed code:


var a = +this.getField("Age").value;
var b = this.getField("Gender").value;

if (a>=45 && b=="Male") event.Value = "+1";
else if (a<=45 && b=="Male") event.Value = "0";
else if (a>=55 && b=="Female") event.Value = "+1";
else if (a<=55 && b=="Female") event.Value = "0";
else event.value = "";


Tags: Acrobat

Similar Questions

  • Is it possible to convert excel function if (and a custom calculation script

    Our field staff use many Excel files for project documentation.  Our organization moves for iPad instead of laptops and we found that a PDF file to be filled on-line is a great resource for our staff.  I have created several of these forms that contain multiple lines and I just starting to learn how to write custom calculation scripts.  I have a more complex than most calculation and I don't know if this can be written in script.

    = IF (I6 < 0.7, G6 * 0.8, IF (AND (I6 > = 0.7, I6 < 0.8), G6 * 0.85, IF (AND (I6 > = 0.8, I6 < 0,9), G6 * 0.9, IF (AND (I6 > = 0.9, I6 < = 1,1), G6 * 1, IF (AND (I6 > 1.1, I6 < = 1,2), G6 * 1.1, IF (AND (I6 > 1.2, I6 < = 1.3), G6 * 1.15, of"extra work"))))))

    I6 is OverdepthRow1

    G6 is WithDowelsRow1

    I think I understand how to get started

    var v1 = get.thisField("OverdepthRow1").value;

    var v2 = get.thisField("WithDowelsRow1").value;

    if(v1<0.7) {}

    var result = v2 * 0.8

    Event.Value = result}

    ElseIf (v1 > = 0, 7 - now I don't know what to do!)

    I hope that I used the correct brackets and braces in the right places.

    I appreciate your help and your advice.

    Thank you

    Rhonda

    I'm sorry, I made a mistake with the first two lines. I have corrected a problem but introduced another. They must be:

    var v1 = + getField("OverdepthRow1").value;

    var v2 = + getField("WithDowelsRow1").value;

  • Mileage reimbursement form (custom calculation)

    I am trying to create a script to custom calculation for a mileage reimbursement form. I have a box titled 'engine miles' and I would like to only by the amount of 2014 de.56 IRS for a refund 'total '. If someone has a formula for this it would be greatly appreciated!

    Create a hidden field with this value (remember to use it as default), and then simply use the built-in function of product in the tab calculate to get the result of the multiplication of these two fields. This will make much easier to edit the file in the future, if need be.

  • Help with a custom calculation for rounding up/down in Adobe Pro

    Hello!  I've never written a custom calculation, so I'm lost; could someone help me please write one round to high-low a.50/.49 with this field name:

    CreditedTotalLocal + OtherHE

    For example, if the value of this field, which is the result of the function "value is the sum of the (+) of the following fields" on two fields named CreditedXXXXLocalHE and CreditedOtherHE - between 3.0 and 3.49, this field should be 3.0.  If the value is 3.50 to 3.99, the field should show 4.0.

    I'm sure it's very simple, but I've tried some things from this and other forums without success.  Help, please!

    Thanks in advance,

    Kim

    Instead of using the "field is the sum of the following fields:" or him simplified "Field Notation" you need a custom as a calculation script

    function myRound (n, d)
    {
    / * By d. P. story
    http://Math.uakron.edu/~dpstory/acrotex/elementary/rounding.PDF
    */
    n = String(n).replace(/^,$/g,""); "
    d =-1 * d
    var m = Math.pow(10,d);
    n * = m;
    n = Math.round (n);
    n / m =;
    d = ( d > 0 ) ? d: 0;
    n = n.toFixed (d);
    return n;
    }

    var nResult = this.getField("CreditedXXXXLocalHE").value + this.getField("CreditedOtherHE").value;
    Event.Value = myRound (nResult, 0);

    or

    function DoubleRound (nValue, nDec)
    {
    var nResult = Math.round (value * Math.pow (10, nDec + 1)) / Math.pow (10, nDec + 1);
    return Math.round (nResult * Math.pow (10, nDec)) / Math.pow (10, nDec);
    }

    var nResult = this.getField("CreditedXXXXLocalHE").value + this.getField("CreditedOtherHE").value;
    Event.Value = DoubleRound (nResult, 0);

    The above two functions to round the values decimal, myRound use - Dec for the decimal value to be rounded so that the DobuleRound use the positive value for the decimal number or powers of 10 as the 1,000 with the 3 myRound and -3 for DoubleRound.

  • If/Then converted to a custom calculation Script

    Can someone help me convert = IF (A2 - A1 > 0, 0, A1 - A2) in a customized for use in an Adobe form calculation Script?

    Thank you!

    If A1 and A2 are field names, then the custom calculation script might look like:

    (function () {}

    Get the field values as numbers

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

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

    Set the value of this field

    Event.Value = A2 - A1 > 0? 0: A2 - A1;

    })();

  • Convert the IF function in the custom calculation Script

    Can someone help me with 'IF(Line7<Line8) Line7, framework8' conversion in a custom calculation Script?

    var L7 = Number(this.getField("Line7").value);
    var L8 = Number(this.getField("Line8").value);
    event.value = (L7		   
  • Custom calculation script

    Hello

    I have some problems eiditing my custom calculation scripts.

    at present, there are: ColorField ('IncubatorLow', ValidateMinMax ('IncubatorLow', 400, 1000) & & ValidateOrder ('IncubatorLow', 'IncubatorHigh'));

    I want to change it

    If (event.value > = 400 & & event.value < = 1000) event.target.textColor = color.black;

    Else if (event.value > 1001) event.target.textColor = ["RGB", 0.5, 1, 0];

    Else if (event.value < 399) event.target.textColor = ["RGB", 0.5, 1, 0];

    But whenever I save my pdf file, it keeps the old one? Although even I tried to delete, lock and so on?

    Under java script, I can't know what is may be the course?

    Any ideas? Thanks in advance!

    Found under Java Script: ColorField runs by Custom Caluclations a string. But if I do one for example a new java script for CustomColors - and change of ColorFields to CustomColors.
    And then save the pdf file, it always uses the Colorfield?

    Just solved the problem.

    The form field name: IncubatorLow - IncubatorHigh - now, I just called them: IncubatorLowColor - IncubatorHighColor, then change the java script for validationminmax and change the colors for my 'java script' CustomColors.
    Can register with it back to the original script.

    I do not understand why change the field can solve it, but it has

  • Custom calculation script % help

    What is the custom calculation script to arrive at a percentage of penetration between two fields? Example: 50 / 100 = 50%

    The simple notation of field: field 1 / field 2

    Custom script:

    var v1 = + this.getField ("Field 1") .value;

    var v2 = + this.getField ("Field 2") .value;

    If (v2 == 0) event.value = "";

    else event.value = (v1 / v2);

  • Help custom calculation

    I need help to write a custom calculation.  That's what I need: I have four boxes (Tone4, Tone1, Tone3, Tone2).  Each box is worth its value (ie. If Tone4 is activated, it should give me 4 points).  How can I write a script that will give me the right value for the checkboxs?

    Tone2 Tone1 ToneScore Tone3 Tone4

    x                                                            4

    or

    Tone2 Tone1 ToneScore Tone3 Tone4

    x                                             3

    or

    Tone2 Tone1 ToneScore Tone3 Tone4

    x                               2

    or

    Tone2 Tone1 ToneScore Tone3 Tone4

    x               1

    or

    Tone2 Tone1 ToneScore Tone3 Tone4

    0

    Why these boxes are named differently? If they are part of an exclusive group (that is to say, you should not check more than one at a time) then they should have the same name but different export values. Then, you can simply set the desired values as the values of export for each box and use this code as the custom calculation of ToneScore script:

    Event.Value = this.getField("Tone").value;

    If (event.value is "Off") event.value = 0;

  • Need help custom calculation Script

    I need to make a script are a column of fields based on or no information found in another column of fields is the same or specific text. Please find below the screenshot of what I would like that to be done.

    I would like a sum of all the amounts that had Code A...

    You can use this script as of 'SumOfA ': custom calculation script

    var total = 0;
    for (var i=0; i<=2; i++) {
        if (this.getField("p1TC."+i).value=="Code A")
            total+=Number(this.getField("p1RecIn."+i).value);
    }
    event.value = total;
    

    You can adjust easily to the other field as well.

  • As a custom calculation, Min and Max with 2 var?

    Is it possible in a custom calculation form select MIN (var1, var2) but a max of 8000. Any ideas would be greatly appreciated?

    The calculation script could be something like:

    Get the values of fields, as strings

    var s1 = getField("v1").valueAsString;

    var S2 = getField("v2").valueAsString;

    If (s1 & s2) {}

    Event.Value = Math.min (8000, s1 + s2);

    } else {}

    Event.Value = 0;

    }

  • Character limit to the custom calculation Script?

    Hello. I have a document that has a text form field. I want to run a custom calculation script which basically says if field 'Number group' = xxxxxxx, so the 'Group name' field should = ABC company.

    I have a list of almost 575 group numbers and names that I need to put in the script. And I have the script works fine, but I'm guessing that there is a limit of characters for the field script? It doesn't let me put my complete list in there.

    Any suggestions on how to work around this problem?

    Thank you

    Brandy

    Yes, there is a character limit for internal JS Editor. The round it is to use an external, such as Notepad.

    Do go to Edit - Preferences - JavaScript and select "Use the external JavaScript editor" and then select the application you want to use.

    Don't forget, however, that you must close the external file each time that change you it if you want to update in the PDF file.

  • Amount of calculations in the statements of fix

    Greetings, wise!

    Is there a setting that limits this sum? I am not sure of the reason for the problem, but I had for example 8 calculations in the statements of fix, when I tried to run this script has shown me an error after I divided these 8 calculations in two separate statements BUT absolutely equal fix with four calculations in each (because I need all 8 calculations for the same difficulty) and it has worked!

    Could someone a suggestion, what reason could be responsible for this?

    p.s. this all started when we installed a patch
    The version is 11.1.2.0.83

    You can set through EAS - http://docs.oracle.com/cd/E17236_01/epm.1112/eas_help/setcache.html
    Stop/start the database if you make changes in the cache.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • How to run multiple sql statements

    Hi all

    I wonder if I can run multiple sql statements in one shot with > >, immediate run

    for example:

    I set the variable as X: = sql statement
    Y: = sql statement
    z: = sql statement

    can I execute immediate (X, Y, Z);

    If yes how? and if not what other possible

    Thank you

    Beginning with the codes of Ganesh

    DECLARE
       l_statement                 VARCHAR2 (2000);
       v_passwd                    VARCHAR2 (200);
       v_username                  VARCHAR2 (200) := 'test';
       v_pwd_key                   VARCHAR2 (200) := 'lwty23';
       v_dblink_name               VARCHAR2 (2000);
       v_dblink_drop               VARCHAR2 (2000);
       v_dblink_create             VARCHAR2 (2000);
       v_dblink_check_connection   VARCHAR2 (2000);
       l_number                    NUMBER;
    BEGIN
       --<>
       FOR c_instance IN (SELECT *
                            FROM v_oracle_instances
                           WHERE environment = 'Developement')
       LOOP
          SELECT encpwd_owner.display_db_encpwd (v_username,
                                                 c_instance.host_name,
                                                 c_instance.instance_name,
                                                 v_pwd_key)
            INTO v_passwd
            FROM DUAL;
    
          v_dblink_name := c_instance.host_name || '_' || c_instance.instance_name;
          v_dblink_create :=
                ' CREATE DATABASE LINK '
             || v_dblink_name
             || ' CONNECT TO '
             || v_username
             || ' '
             || 'IDENTIFIED BY '
             || v_passwd
             || ' USING'
             || ' ''(DESCRIPTION=
    (ADDRESS=(PROTOCOL=TCP)(HOST= '
             || c_instance.host_name
             || ')(PORT='
             || c_instance.LISTENER_PORT
             || '))(CONNECT_DATA=(SID='
             || c_instance.instance_name
             || ')))''';
          v_dblink_check_connection := 'select 1 from global_name@' || v_dblink_name || '.QCM';    --- Notice this change. I am simply selecting 1. That should be enough to test the database link.
          v_dblink_drop := 'drop database link ' || v_dblink_name || '.QCMTLAF';
    
          -- l_statement := 'BEGIN ' || v_dblink_create ';' || v_dblink_check_connection ';' || v_dblink_drop '; END ;'
    
          BEGIN
              EXECUTE IMMEDIATE (v_dblink_create);
              DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Created');
         EXCEPTION
            WHEN others THEN
               dbms_output.put_line( 'Failed to create the database link ' || v_dblink_name  );
               dbms_output.put_line( dbms_utility.format_error_backtrace() );
               INSERT INTO error_table( column_list )
                 VALUES( <> );
         END;
    
          EXECUTE IMMEDIATE (v_dblink_check_connection) INTO l_number;    --- Notice this.
    
          DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Tested');
    
          BEGIN
             EXECUTE IMMEDIATE (v_dblink_drop);
             DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Dropped');
          EXCEPTION
             WHEN others THEN
               dbms_output.put_line( 'Failed to drop the database link ' || v_dblink_name  );
               dbms_output.put_line( dbms_utility.format_error_backtrace() );
               INSERT INTO error_table( column_list )
                 VALUES( <> );
         END;
       END LOOP;
    END;
    

    But I agree with the comment that others have grown up is not really wise to create and drop a database like that link.

    Justin

  • I can't get this if/calculation of the statement of work


    In an Acrobat form I want to check to see if a field check box has been checked (value = yes) and if this is the case, put a specific, static number in another field. That's all.  Seems simple, but I can't understand it.  (Excel - Yes.  Acrobat Script - no.)  Help, please! Thanks in advance.

    In the target custom calculation of the field, enter this:

    If (this.getField("checkbox1").value == "Yes") {event.value = 12 ;}

    You will need to change the name of the field box (between quotes)

    and of course the value that you want to apply.

Maybe you are looking for