IF THEN statement JavaScript

I'm figuring the total number using the following:

I have 8 rows with three columns that will feed into a calculation based on what is selected in a collection of drop boxes

Element (value: description), metric (value: number); FabricType (drop-down list values: PW, HLP, HC, CHU)

The fields with the calculations are: HC Total, PW Total, Total HLP and UHC Total.

I need calculate totals across all 8 rows IF the selected tissue Type match the amount requested.

So, if:

Element FabricType metric

A                    4.00               PW

B                    5.00               PW

C                    1.00               HLP

D                    3.00               HC

E                    9.00               PW

F                    3.00               UHC

G                   4.00               UHC

H                    3.00               HLP

What is the javascript code to compute each of the following fields:

Total UHC

Total PW

Total HLP

Total HC

based on the drop down FabricType, and which is entered in the metric field

Well I found it on my own to another post in this forum.  Here is the script that I used and it works beautifully!

function SumIfEq (aIndex, aRange, cValue) {}

function to calculate the amount for item cIndex cRange equals cValue;

do not change the code below;

nSum var = 0; variable of type of sum of payment;

check that there is an equal number of fields;

If (aIndex.length! = aRange.length) {}

App.Alert ("the number of fields m and tissue must be equal!", 0, 0);

} else {}

Browse fields

for (i = 0; i< aindex.length;="" i++)="">

If (this.getField(aIndex[i]).value == cValue) {}

Add the payment of the amount;

nSum += Number (this.getField(aRange[i]).value).

} / / end match of payment type;

} / / end of loop through the fields;

} / / end of field length.

return nSum; return the sum calculated;

} / / end of function SumIfEq

script for calculating customized by using the function SumIfEq;

the use of tables of domain names;

aIndex var = new Array ("GFM_e1_t", "GFM_e2_t", "GFM_e3_t", "GFM_e4_t", "GFM_e5_t", "GFM_e6_t", "GFM_e7_t", "GFM_e8_t");

aRange var = new Array ("GFM_e1_m", "GFM_e2_m", "GFM_e3_m", "GFM_e4_m", "GFM_e5_m", "GFM_e6_m", "GFM_e7_m", "GFM_e8_m");

call amount if equal payment 'Type' of 'Amount', 'HC ';

Event.Value = SumIfEq (aIndex, aRange, "HC");

end of custom calculation script;

Thanks @GKaiseril ... even if you did not know you helped!

Tags: Acrobat

Similar Questions

  • How to do an if then statement on a PDF form

    I'm doing an if then statement on a PDF form.

    The field is a field A * B = C.  If C < 10 then C = 10, of another C = A * B

    How can I write the Adobe Pro is on a PDF form?  I went into properties, the calculated field and nothing I've tried works.

    Each field is a separate object, so if you have 3 fields such as 'A', 'B' and 'C' are a single object has a unique value. Each field must be consulted individually, you should get the value in field "A" in a statement, the value of the field 'B' in another statement.

    var C = this.getField ('A') .value * this.getField("B").value;

    If (C)< 10="" )="" event.value="">

    else event.value = C;

    You can see more clearly with code like:

    var A = this.getField ('A') .value; the value of a field;

    var B = this.getField ('B') .value; the value of field B;

    var C = A * B; the field value has multiplied by the value of the field B;

    If (C)< 10="" )="">

    Event.Value = 10; the value is 10 when produced less than 10;

    } else {[]}

    Event.Value = C; another value is the product;

    }

  • If then statements

    Greetings,

    I use Adobe Acrobat Pro XI.  I have a drop down list which has the value 'Yes' or 'No' I would like to create an If Then statement to return specific values in another field of text based on the value of the drop-down list box.  Specifically, if the value of the 'drop-down list' = 'no', then the value of the "textfield2' will be 'n/a '.  If the value of the drop-down list is 'Yes', then the value of the "textfield2" remains empty if the applicant can enter data into "textfield2.

    Hope it makes sense.  Thank you in advance.

    Steve

    Use this code in the script validation custom from the drop-down list:

    If (event.value == "No") this.getField("textfield2").value = "n/a";

    else this.getField("textfield2").value = "";

    Make sure that check the option to validate the value selected from the drop-down list immediately (under Properties - Options).

  • If/Then statement to date null in Acrobat DC

    I work in Acrobat DC, I have a document which is 6 pages long, the first page is in English, the other in Spanish.

    I have two date fields, one is named AssessmentDate and the other is LongAssessDate. AssessmentDate displays the date in English in mm/dd/yy format on the first page.

    The LongAssessDate field converts the date in the field of the AssessmentDate in a Spanish format. For example if the Valuation Date
    24/05/15 then the date is converted to this format = 24 Mayo of 2015.

    Here is my code:

    oField var = this.getField ("AssessmentDate");

    oDateObject = util.scand ("mm/dd/yy", oField.valueAsString);

    Event.Value = util.printd ("date (es) {DD ' of 'MMMM' to ' YYYY}", oDateObject, true);

    What I found is, if the user does not have a date in the AssessmentDate field (they leave empty), the current date watch in the
    Field of LongAssessDate.

    I think I need an if/then statement for the LongAssessDate field. If the value of AssessmentDate is null or empty, then the LongAssessDate field must be null/empty, but don't know how to proceed. Any help is greatly appreciated.

    Thank you, Jamie

    This should work:

    var sDate = this.getField("AssessmentDate").valueAsString;

    If (sDate) {}

    oDateObject = util.scand ("mm/dd/yy", sDate);

    Event.Value = util.printd ("date (es) {DD ' of 'MMMM' to ' YYYY}", oDateObject, true);

    } else {}

    Event.Value = "";

    }

  • New on Adobe need help with an if then statement

    Hi, I really like what ADOBE Pro 9 can do with forms and neat and everything is included.

    I'm having a problem trying to understand an if then statement for one of my forms and how to make it executable.

    Here is what I have

    I.          Cigna Medical                                           

                (10)       single                                     $  44.00

                (11)       Employee & Child (ren)              $  82.00          

                (12)       Employee & Spouse                 $  99.00                      

                (13)       Family                                     $125.00                      

                (14)       Decline Coverage                         $0.00          Choice: _        Amount: $_

    An employee will be choice an optiopn 10-14 and but that number of choices. After I am about to fill with this number.

    For instnace, if an employee takes option 11, choice: 11 and amount: $ 44.00

    I put the options in a menu drop-down. The drop down menu is titled CignaMedical and Amount_1 title for amount: $_ and I made a text box.  I put this code: if (this.getField("CignaMedical").value == '10') {}
    Amount_1 = 44.00} tab calculation of properties for the Amount_1 of text box on the custom calculation script tab.

    Any help is greatly appreciate

    Yes, you can use an if-else if construction. Something like that (I got the first part because we reuse it):

    CignaMedical = this.getField("CignaMedical").value;

    If (CignaMedical == '10') {}

    44.00 = Event.Value;

    } Else if (CignaMedical == "11") {}

    Event.Value = 82.00;

    } Else if (CignaMedical == '12') {}

    99.00 = Event.Value;

    }

    etc.

  • If/then statement

    I am designing a form that has 2 columns and I am looking for a script to fill a column based on data in the other.  Specifically, if classes has, B, C, D are entered in the column on the left, then the right column filled with 3 hours of credit.

    I took a fairly simple if/then statement... Found one in the help section of my software, plugged, named fields properly in the object palette and in the script.  No go.

    Book Terry JT not useful and my computer is not versed in Java.

    Or, maybe I'm doing it too hard and FormCalc would be the right choice?

    Thank you!

    Hi Milly,.

    You didn't say what else is in the grade or the opportunities that lay is A +, B-, etc. AND they are in a table row. I suppose they are in a table. I think on a drop-down list for the grade box. That said, this might work for a drop-down list box or a text field containing the grade (depending on how you have the menu drop-down set up) or this script is changed for a drop-down list containing the digital item values in the 'Connection' tab easily. It lends itself to the computer GPA (if it is an ultimate goal).

    Grade Credit
    A 3
    C 3
    F 0
    A 3

    The script is quite easy.

    Make sure you place this on the calculate of the "credit" field event AND formCalc is the language:

    ////////////////////////////

    If (rank< "f")     ="">

    $ = 3

    on the other

    $ = 0

    endif

    ////////////////////////////

    If there is + or - grades, you could use

    ////////////////////////////

    If (Substr (grade, 1, 1)<  "f")     ="">

    $ = 3

    on the other

    $ = 0

    endif

    ////////////////////////////

    La: Substr(grade,1,1) from the 1st letter of the slope and uses for comparison

    Replace with the name of your field of rank for the "rank" above and you should be good to go.

    Good luck

    Stephen

  • If - then statements (k)

    Honestly, I don't know how to write any PHP, but I don't know how to create a PHP website in Dreamweaver because DW wrote all the PHP for me.

    I think that I now need to get out a bit of Dreamweaver. What I would do is:
    If the variable width = 800, so I want to show a specific hidden layer.
    If the variable height = 800, so I want to show a specific hidden layer.

    I could do that in a second in ActionScript, but I have no idea how to go about this in Dreamweaver.

    How would one write an If - then statement?

    Don't forget, all this PHP code that creates DW is like hieroglyphics to me.

    Thank you
    -Kirk

    xparrot_dude wrote:
    > I'm not having much luck. I don't know where to put the if-then you have written or if
    > the $width is a standard PHP type thing or if it is a variable.

    It is a variable. In PHP all variables begin with a dollar sign.

    > Here's what I tried:
    >
    ><>
    > If ($width == 800) {}
    {$show > visible =}
    > {else}
    $show > = hidden
    > } ?>

    You would not assign a string to a variable in ActionScript without using
    quotes. It goes the same for PHP. In ActionScript, the semicolon at the end
    a statement is optional (but recommended recommended). In PHP, there
    mandatory.


    <>
    If ($width == 800) {}
    $show = 'visible' ;}
    else {}
    $show = 'hidden ';
    } ?>

    > I then put the $show variable in my css, like this:
    > #HorizontalPhoto {}
    > position: absolute;
    > left: 53px;
    > top: 159px;
    > width: 317px;
    > height: 172px;
    > z - index: 1;
    > visibility: $show;
    > }

    The only thing that can go in CSS is CSS. If you want to use PHP, you
    must surround yourself with PHP tags and use echo or print to the output of the
    the value of the variable.

    visibility: ;

    > Please keep in mind that I've never written ANY PHP. So I don't know if I
    > need the tags or even where I can and can not put code.

    Everyone is a beginner at one point, but you will get better help if you
    make an effort to begin to learn some PHP basics yourself. A good place
    to start is with the official PHP tutorial:

    http://docs.php.net/manual/en/getting-started.php

    You will also find the PHP language useful reference, especially if
    you are already familiar with ActionScript. The two languages share many
    in common:

    http://docs.php.net/manual/en/langref.php

    --
    Adobe Community Expert David Powers
    Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Adding values of mulitple tables in a loop with if then statement

    So I a table set in place and need to add the hours of specific activities.

    I have Activity() as an array of drop-down boxes with things like ' holiday, regular, vacation, etc.

    Monday(), Tuesday() etc., are numeric field berries.

    and I try totals of population since the differnet activities.

    Use of Java like this and it doesn't seem to work:

    for (var i = 0; i < 12; i ++)

    {

    If (activity [i] .rawValue = 'Holiday') {}

    $. Monday = value [i] .value + Tuesday [i] .value + Wednesday [i] .value + Thursday [i] .value Friday [i] .value

    }

    }

    Am I missing something here?

    Hello

    Use FormCalc (not JavaScript). I think that you have a 'total' field for each week (i.e. total and Monday are brothers and sisters?). If so

    //////////////////////////////////////////////////////////////////////

    If ( == 'Holiday' activity) can

    $ = Sum (Monday, Tuesday, Wednesday, Thursday, Friday)

    on the other

    $ = 0

    endif

    //////////////////////////////////////////////////////////////////////

    If you are adding up for several weeks (weekly).

    If (activity == 'Holiday') then

    $ = Sum (Monday, Tuesday, Wednesday, week [*] [*] the week of the week [*] [*] the week.) Thursday, the week [*]. Friday)

    on the other

    $ = 0

    endif

    where each group of days is encapsulated in a subform named "week".

    //////////////////////////////////////////////////////////////////////

    Finally, it uses the values "boundItem" NOT the displayed value. So:

    If ( == 'Holiday' activity) can

    works only if the value of boundItem is used. Look in the BindingTab for the drop-down list to understand and configure certain boundItem values. They are strings and use "" when you reference strings. So 1 is better referenced as '1' as in

    If ( == activity '1') then

    //////////////////////////////////////////////////////////////////////

    Finally, if needed of statements == (do not use a single =).

    I hope this helps!

    Stephen

  • using nest if then statements using ABM

    I have a two input, 1 output circuit, as in the attached schema. My third node is set down by the very high resistance voltmeter. What I have is a user defined current source ABM that depends on other parameters in the circuit. I wonder it is what my conditional statement is entered in the right format? Conditions are particularly complex and describe as follows:

    If the voltage difference between V2 and U1 is greater than 0, then the current in the ABM = 10 ^-12

    If this voltage difference that the above is not greater than zero and if (V (1) u (1))<(V(2)-U(1)), then="" the="" abm="" current="" is="">

    Otherwise, if (V (1) u (1)) > = (V (2) u (1)) then the current is (0.1*((-(V(2)-U(1)))^0.35))*0.00001596*(((V(2)-U(1))^2)/2)

    As you can see, they are very complex conditions and my concern is that I can't just type in U1 and get the compiler to understand I want the voltage read on the voltmeter of bottom-node. I think I'm using the correct nesting in the encoding format is: if (T, X, (if(Q,R,S))).

    Any help would be appreciated, and details can be provided.

    I don't know why its not throwing an error for the use of u (1), maybe it's a valid keyword.

    If you want to reference a voltage properly, it should be V (net_name) for single ended voltages (referenced to ground) or V (net1, net2) for differential voltages... For models ABM I suggest turning on net visibility throughout the schematic so that you know the net name to the positive terminal of U1 or anywhere else for that matter.

    I think the syntax you have to if/then/else is correct otherwise.

    Kind regards
    Pat Noonan
    National Instruments

  • Number of fields with If then statement

    Greetings,

    I use Adobe Acrobat Pro XI.  "On a form I created, there are fields named"RLRow1", RLRow2," RLRow3 "etc all the way up to RLRow13, assuming that there are 13 lines of data that need to be registered.  The staff is required to enter the letter 'L' or the letter 'R' in these areas.  I have already added the Custom Format Script of ' event.value = event.value.toUpperCase (); "to convert uppercase text.  On this form, I have a field called "Total L" and a field called 'R Total'.  I would like to add a javascript function which counts the number of 'L' RLRow1, RLRow2 etc and put the total in the field 'Total L '.  Likewised, I would like to add a javascript function that counts the number of 'R' RLRow1, RLRow2 etc. and puts this total in the field 'Total R '.  I guess it would be some type of instruction If Then, but I'm not familiar enough with Javascript.  I hope that's not too complicated.  Can anyone help with this?

    First, if these are the only values allowed then use a drop-down list instead of a text field, but never mind.

    You can use the following code in the custom calculation of the field 'Total L' script. It is easily adjusted for the field 'Total R' thus:

    var total = 0;
    for (var i=1; i<=13; i++) {
        if (this.getField("RLRow"+i).valueAsString=="L")
            total++;
    }
    event.value = total;
    
  • If then statement help

    Thanks in advance for your help. I work on a PDF form and has difficulty with a logical statement (If Then). Then the field (TotalEligibleServiceCatchup) should be the least of the three amounts: TotalElectiveSalaryDeferralMinusYearsOfServiceCatchup, LifetimeMinusCatchupAmount, or $3,000. In other words, if the Total salary deferral less years of Service catch-up is like $3,000 and life less amount of catch-up is greater than $3,000; the value of the calculated field is $ 3,000. If one or both of the first two values are less than $3,000, the calculated field is the least of these values.

    Thanks in advance for your help.

    In this case, you can use this code as the custom of your domain calculation script:

    var v1 = +this.getField("TotalElectiveSalaryDeferralMinusYearsOfServiceCatchup").valueAsString;
    var v2 = +this.getField("LifetimeMinusCatchupAmount").valueAsString;
    event.value = Math.min(3000, v1, v2);
    
  • Fire of action first and then dynamic javascript

    Hello

    I use Oracle Apex 4.1.

    In one of my fields of data in reports, there are a few fields with hyperlinks.

    Ex: I report and one of the field shows 'Enter Code', so when the user clicks on 'Enter the Codes' URL it triggers a javascript that sets the hidden item-specific value and opens a modal form to enter the codes.

    When the form opens, if there is no value for the codes, I need to show the codes in the form so I want to write a dynamic action that sets the values once the form opens.

    My requirement is:

    When you click on a link, call javascript set on the page and then call a dynamic action.

    I need to call javascript from the url that I need to set some parameters is passed to javascript.

    Hello

    I found something, what would be interesting to launch dynamic javascript actions.

    But make sure that you do not change the order of dynamic actions.

    Make a call to it from your javascript code

    Apex.da.actions ($("#P5_HID_TEST"), apex.da.gEventList [1], "change", null);

    actions : function(pSelector, pEvent, pBrowserEvent, pData)

  • If then statement - hide the field 0 and counting! Help!

    OK, I try to have the Cap RATE: to do a number of things. On the side of first note, in the Privileged Postion there drop down there has 4 options, 1 fixed, 2 ch, HELOC 1st and 2nd HELOC. I'm figuring the CEILING using the APOR , if the Position of privilege claims fixed 1st or 2nd set only. So that the calculation of the ceiling RATE should read something like this, IF (States ofPrivilège Position : Fixed 1st or 2nd set then ADD (fixed 1 IF add 1.5% IF the 2nd ch ADD 3.5%) rate APOR (users will enter rate APOR).)

    EXAMPLE:

    Position of privilege: 1st set

    APOR: 3.48%

    (because it is the 1st ch)

    + 1.5%

    CAPP RATE = 4.98%

    EXAMPLE 2:

    Position of privilege: 2nd set

    APOR: 3.48%

    (because it is the 2nd ch)

    + 3.5%

    CAPP RATE = 6.98%

    Also, I want the CEILING to be TRANSPARENT or WHITE if there is no rate entered MRPS because it's to RATE FIXED ONLY.

    Capture.JPG

    Any help is greatly appreciated!

    Ok

    This can be done easily with a FormCalc script in the calculate the rate ceiling field event.

    Assuming that the other fields are named LienPostion and MRPS, the script looks like:

    if (LienPosition eq "1st Fixed") then
              APOR + 1.5
    elseif (LienPosition eq "2nd Fixed") then
              APOR + 3.5
    else
              APOR
    endif
    
  • variables php correctly loaded in flash and poster DEFY the If - then statements

    path = "http://localhost/xampp/nwjv/php/";

     

    //declare path to php files

    lvOut = new LoadVars();     //create lv object sending variables OUT to php

    lvIn = new LoadVars(); //create lv object receiving variables IN from php 

     

    lvIn.onLoad = function (success) {

    if(success)

    {

         //PHP variable value to textbox 

     

         InVal = lvIn.returnVal;

         InTxt = lvIn.retVal; 

     

         output.text = InVal;

         output1.text = InTxt; 

        

         /* 

        output1.text = "No Value"; 

         if(InTxt == 'lo' ) { output1.text = "Low Value"; } 

         if(InTxt == 'hi') { output1.text = "High Value"; }

          */

    } else { //...or notify of failure output.text = "fail"; }

     


    myBtn.onRelease = function()

      {

          //assign user-input value to lv property called years

         lvOut.years = years.text; //send to a blank window //

         lvOut.send(path + "dogyears_new1.php",lvIn,"GET");

         lvOut.sendAndLoad(path + "dogyears_new1.php",lvIn,"GET");

    };

    And simple PHP code

    PHP code:

    <?php$calculation = $_GET["years"]*2;
    if(
    $calculation <=10 ) $retVal="lo";
    if(
    $calculation > 10$retVal="hi";
    echo
    "&returnVal=$calculation &retVal=$retVal" ;?>

    PHP returns two values that are perceived by the flash in InVal and InTxt variables. The collected values are correct and are thus displayed in boxes of 2 outputs. If the value in the input box is 5 or less, the outbox1.text shows "lo" and if the entrance area is greater than 5 the output1.text shows 'hi. '

    Now, if yew commented then block in the code is activated by removing the / * / of all about him and the program is run, the If Then block fails because the comparison of the InTxt fails.  SO even if the value of InTxt is "hi" or "lo" as seen on the 1st round, but the value does not change to the 'Value' but high 'low value' according to the value of InTxt in the If Then comparison bloac.


    It has completely failed me why this is happening. While I can see the values correctly, I can't use it in conditional loops. I even tried the instructions box switch with the same frustrating result. (The output1.text is equal to 'No value' when it should change to 'High value' or 'Low value')

    Earlier I was using numbers and faulty when I tried to use strings because I thought that for some reason any PHP returns everything as strings. But as can be seen, even the string comparison fails.

    Can someone please comment on this problem and suggest a solution.

    All thanks loads!


    PS. I wanted to download the small fla for this but I could not find a way to add a file here. Please suggest if I can do and how and I'll upload my fla for this code. Thank you.

    which is caused by some problems/string number (not in your case), or a white space (probably your situation).

    to confirm that it is the white space, check the length of returned variables to see if they are more than 2.

  • Else if then statement help

    Hi, I'm doing a script for a submit by email button pick up two fields of the subject - an id and the date line.  The problem is there are two date fields and I want only to pick up one of them.  So if the first is empty (that is, "home_insert_date") he will get the second one (i.e. "apt_insert_date"), and if the first is filled, then it will ignore the other.

    Here's the current code that I have.

    var parts = getField("newspaper_flyerid").value + '-' + getField("home_insert_date").value + getField("apt_insert_date").value
    this.mailDoc({)
    cTo: " [email protected] ", "
    bassujetti: parts,.
    });

    Thank you very much!

    Try this:

    var part1 = this.getField("newspaper_flyerid").valueAsString;
    var part2 = this.getField("home_insert_date").valueAsString;
    var part3 = this.getField("apt_insert_date").valueAsString;
    
    var subjectLine = part1 + "-";
    if (part2=="" && part3=="") {
        subjectLine += "missing date";
    } else if (part2!="") {
        subjectLine += part2;
    } else subjectLine += part3;
    
    this.mailDoc({
        cTo: "[email protected]",
        cSubject: subjectLine
    });
    

Maybe you are looking for

  • HP Office Jet Pro 8600: nothing prints

    The printer queue says "the printer does not. I checked the wireless connection and everything seems fine. I cleared the print queue and restarted the printer.  But still nothing prints. Help! Please, I beg you!

  • 32-bit Windows 7-64 bit software up and running?

    I plan to get a new laptop with 64-bit, Windows 7 Professional. Can you tell me if I do not receive 64-bit, I still will be able to load all my packages of 32-bit software on a Windows 7 64 bit and will they run right with Windows 7 64 bit? Thanks fo

  • The mouse flashes with the loading circle.

    Hello. I'm on Windows 7 Professional on a custom pc, and since yesterday kept my blinking cursor and flicker with the blue spindle, but when I hover over text when the cursor looks like a capital "I", it stops flashing and turns into normal, yet when

  • Windows 7 stucks on the Welcome screen

    Hello I am using windows 7 ultimate and I had a problem as my stucks windows 7 on welcome screen even though it is running in safe mode... Help, please! concerning

  • How to disable the BasicEditField certain events?

    Hello How can I turn off the BasicEditField some specific events... is it possible? Thank you best regards &,. Narendra.