Conditional if... else statements populate another field

Hello

new to the forum. A big shout out to all those who help people like me. It is greatly appreciated not only to solve the problem but helps us to learn as well.

I looked at other issues and don't quite understand what I'm looking for. Java script seems to make up my mind what the...

Scenario:

I have a form of credit card and I want to calculate a surcharge on the transaction amount.

Type of card ("card" field) is chosen from a drop-down list and the value can either be Visa, MC or Amex, with export value of 1, 2 or 3 respectively.

The amount of the transaction is entered in the field "amount". At the exit of the "amount" box, I want the "supplement" to be automatically populated with a calculation field. This calculation is:

If 'card' = 1 then 'supplement' = 'to' *.01

on the other

If 'card' = 2 then 'supplement' = 'to' *.03

on the other

If 'card' = 3 then 'supplement' = 'to' *.05

I have one more field 'total' that will be the value of the sum "amount", "Supplement".

The other part is if the wrong card was first chosen (for example the seller chose Visa but it should have been Amex) I would like to as the field "supplement" to recalculate automatically at the exit of this field.

Any assistance, advice would be greatly appreciated.

Thank you

Kudurider

You can use this code as the custom to "subcharge": calculation script

var card = this.getField("card").valueAsString;
var amount = Number(this.getField("amount").valueAsString);
if (card=="1") event.value = amount*0.01;
else if (card=="2") event.value = amount*0.03;
else if (card=="3") event.value = amount*0.05;
else event.value = "";

Tags: Acrobat

Similar Questions

  • How to change the fill color of a field from another field condition

    I wish I had a field turns red if the value of another field is greater than 0.2 and would like to know in what format the fields should be.

    I have this code in the text field properties > custom calculation script field, but it is funny:

    var x = getField("fill_35").value

    If (x.value > 0.2)

    event.target.fillColor = color.red

    And the size of the active field is set to 'None' and 'fill_35' is set to 'number '.

    Furthermore, "fill_35" is the difference between the other 2 fields.

    I have this code text field properties > custom calculation script field for 'fill_35'.

    var v1 = getField("Locked.25").value;

    var v2 = getField("Locked.49").value;

    If (v1! == ' ' & & v2! == "")

    Event.Value = v1 - v2

    on the other

    Event.Value = "0.00".

    Help, please. Thank you in advance!

    Have you checked the JS Console to find errors? You can share the file in question?

  • How to use an IF ELSE statement and the xdoxslt: get_variable together?

    First of all, I'm a big fan of this forum and I would like to thank the community for helping to make better the world BI Publisher.

    I'm trying to populate a table with a value of years of data with column = PRODUCT and row = month to DATE. Here's the catch, not every month will be given. Then here's where is my problem, I am not able to use an IF ELSE statement with an expression XDOXSLT:GET_VARIABLE so that if there is no given for this month the default value will be 0.

    Can someone help me find a solution to one of the attempts below or a method entirely new? Thank you!

    BP4 = numeric value of months with a DATE (more code to extract only the month DATE not included here)
    JAN1 = PRICE if there is data, 0 otherwise

    (1) I tried and it did not work:
    <? If: xdoxslt:get_variable($_XDOCTX,'BP4'), 01 xdoxslt:set_variable($_XDOCTX,_'JAN1',PRICE) then another end if xdoxslt:set_variable($_XDOCTX,_'JAN1',0)? >
    <? xdoxslt:get_variable($_XDOCTX,'JAN1')? >
    <? end if? >

    (2) I tried and it did not work:
    <? xdoxslt:IfElse (xdoxslt:get_variable($_XDOCTX,'BP4') = '01', xdoxslt:set_variable($_XDOCTX,_'JAN1',PRICE), xdoxslt:set_variable($_XDOCTX,_'JAN1',0))? >
    <? xdoxslt:get_variable($_XDOCTX,'JAN1')? >
    <? end if? >

    (3) I tried and it did not work:
    <? xdofx:If xdoxslt:get_variable($_XDOCTX,'BP4') = '01' xdoxslt:set_variable($_XDOCTX,_'JAN1',PRICE) then another end if xdoxslt:set_variable($_XDOCTX,_'JAN1',0)? >
    <? xdoxslt:get_variable($_XDOCTX,'JAN1')? >
    <? end if? >

    example of XML data:
    < ROW >
    < name > Craig Hernandez < / NAME >
    < DATE > 2013 - 01-01 T 00: 00:00.000 + 08:00 < / DATE >
    < PRICE > 31 < / PRICE >
    BPD of < PRODUCT > < / PRODUCT >
    < / ROW >


    -TRD

    Published by: 990965 on February 28, 2013 08:27

    >
    (1) I tried and it did not work:


    (2) I tried and it did not work:


    (3) I tried and it did not work:


    >
    so

    
    
    

    works for me, it's

  • How to get a selection of drop-down list to complete another field with nothing

    Hello

    I have a drop down menu that fills another field according to what is selected (as shown here where Admin mistakes fills the next field with 6735-10-01).

    Capture-1.JPG

    However, there are 3 items in the drop-down list that I don't want to fill in the other with (basically, it must be empty during one of these 3 elements are selected, in contrast to how it returns zero in the example below). I don't know what to put in for the values to make it white.

    Capture-2.JPG

    Please notify.

    Kind regards

    ZeroZone

    I don't know what your code looks like or where it is but you will need to add a conditional statement, such as:

    If (DropDown.rawValue == "0" | ") DropDown.rawValue == "1" / * | "" etc, etc, * /)

    TextField.rawValue = null;

    on the other

    TextField.rawValue = DropDown.rawValue;

    Kyle

  • JavaScript custom for If/Then/Else statement code

    Can someone help me understand this code. I have a field in a PDF file that I need to generate a discount based on the price of an item. If the price is higher than 5000, then I need the field to say 1500. Otherwise the field discount must be price *. 30.

    I tried, but it did not work: if price > 5000 then discount = discount 1500 = price*.3

    Someone at - it help?

    Thank you!

    Acrobat forms use JavaScript, so you need to use the JavaScirpt syntax for JavaScript syntax appropriate for the 'If... else' statement. You will also need to access the domain object as established by the Acrobat JavaScript object using the method "getField" of the doc, "this.getField (cName)" object, then the property "value" for this object.

    custom calculation script for the ' discount field

    establish the name of the price field

    var c = "price";

    get the value of the price field

    var nPrice = this.getField (c) .vallue;

    Assume that the discount is 30% of the price

    NPrice = Event.Value * 0,30;

    the value of reduction 1 500 if the price is higher to 5,000

    If {(nPrice > 5000)

    Event.Value = 1500;

    }

    end of the custom calculation script

    For more information, see Conditional Execution by Thom Parker.

  • Apply drop-down selection field to another field in the document

    I'm trying to populate a field on page 2 with the selection of a field of drop-down list on page 1 of the pdf linked dynamic XML (http://www.screencast.com/t/NTRiZmQxNTE).

    In "Subform2, the drop-down list field is named,"subformOptions".» By clicking on this field and opening "change *" will display the statement on the merits that I entered:

    FISupplierGroup.rawValue = xfa.event.newText;

    I was hoping that this statement could fill out the results of the selection of the menu drop-down of the named field, "FISupplierGroup" located in "Subform9" on page 2.

    My results have failed.

    Can someone help me with the solution.

    Thank you

    Eric

    do as "Subform9. " FISupplierGroup.rawValue = xfa.event.newText; " ", it will work.

    This field is not accessible from the inside of an another subform without Subform9.

    RAMBEAU.

  • If the field value is &gt; 1, go to another field

    I hope someone can help me with this question

    If a customer fills in a field with a number that is > 1, I want the cursor to go to another field automatically.

    I used the script:

    before var = this.getField ("some")
    If (before! = 1).
    {
    this.getField ("Naam intro") .setFocus ();
    }

    But it does not work.

    Hoping to hear from you. Thanks in advance.

    Do you receive error messages in the debug console JavaScript?

    You must use "If"not "If" for the if control statement. "

    The comparison operator for the one who is ' > 'and not "!" "=", not equal to.

    Have you tried to access the value of the field object, not the object of field?

    debug information
    oepn the JavaScript debug console:
    Console.Show ();
    Console.clear();
    before var = this.getField ("some")
    Console.println ("typeof some:" + typeof before);
    Console.println ("some value:" + aant.value);
    Console.println ("typeof Aantal.value:" + typeof aant.value);
    the compartive operator test results
    Console.println ("aant.value< 1:"="" +="" (aant.value=""><>
    Console.println ("aant.value<= 1:"="" +="" (aant.value=""><>
    Console.println ("aant.value == 1:" + (aant.value == 1));
    Console.println ("aant.value! ("= 1:" + (aant.value! = 1));
    Console.println ("aant.value > 1:" + (aant.value > 1));
    Console.println ("aant.value > = 1:" + (aant.value > = 1) "");

    If (before! = 1) {}
    Console.println ("before! = 1 ") ;
    } else {}
    Console.println ("before! = 1 not true ");"
    }

    If (aant.value! = 1) {}
    Console.println ("aant.value! = 1") ;
    } else {}
    Console.println ("aant.value! = 1 not true");
    }

    If (aant.value > 1) {}
    Console.println ("aant.value > 1");
    } else {}
    Console.println ("aant.value > not true 1");
    }
    complete debugging code

    If (before! = 1).
    {
    this.getField ("Naam intro") .setFocus ();
    }

  • Match the last 2 characters of field of 1 to 2 characters of another field

    Hi, I was looking for assistance with regard to get output when the last 2 characters of 1 on the ground of the last 2 characters of another field of a particular job, i.e. repair or the new job. Here's an example of my 2 tables and insert queries.

    [code]

    CREATE TABLE 'SITES '.

    (

    'CODE' VARCHAR2 (7 CHAR),

    VARCHAR2 (27 CHAR) "NAME."

    'SITE_NAME' VARCHAR2 (32 CHAR)

    )

    Insert in SITES (CODE, NAME, SITE_NAME) values ('CAFC', 'Central', 'Birmingham');

    Insert in SITES (CODE, NAME, SITE_NAME) values ('MRCE', 'Central','Manchester ");

    Insert in SITES (CODE, NAME, SITE_NAME) values ('LVCE', 'Central', 'Liverpool');

    Insert in SITES (CODE, NAME, SITE_NAME) values ("WSCE", 'Central',' West of Central Scotland ");

    CREATE TABLE 'JOBS '.

    (

    VARCHAR2 (20 BYTE) "JOB_REF."

    'JOB_TYPE' VARCHAR2 (20 BYTE)

    )

    Insert into JOBS (JOB_REF, JOB_TYPE) values ('FFR53CM', 'Repair');

    [/ code]

    So I would take the first 2 characters 'CM' of the Sites Table and at last the match 2 characters of the job Table if the Type of job is the repair and then display the value of the Site name. The reason why I need to filter on the Type of employment is because when a new job is connected so I need to use the first 2 characters rather than the last 2, but I thought I would break it down in order to get the work of part 1.

    Unfortunately I do not know how I can display it, also do not know whether to use a case statement, but still don't know how to write it.

    If someone could please advise, really appreciate it.

    Thanks in advance.

    976439 wrote:

    How I guarantee that it is only for the repair of Type of work?

    You know the SQL language don't you?

    What is the problem with everything by adding:

    where job_type = 'repair '.

    to the query.

    Blimey! I don't think I would be hand-holding today.

  • Trying to create a trigger that adds a value to a field based on another field

    Hello

    Im trying to set a trigger that will add a field to a table if another field = the same thing and one where the condition is met, but can't seem to get anything to do and can't find anything online suggesting the syntax.

    the use of im tables are

    Applications_History

    Students

    I need the trigger to identify if the 'status' field = applicant accepted when a new data column is added, if that is the case I need to identify the scope of student_number of applications_history and match it to the student_number on students field, I then need to add a 'Y' in the field 'put' corresponding to this student in the student table. I'm looking for without stopping for some type of syntax format online but could not find anything, is it still possible?

    Thank you

    Something like that?

    create or replace trigger aiur_applications_history

    after insert or update on applications_history

    for each line

    Start

    If nvl (: old.application_status, 'x'). = 'candidate admitted '.

    and: new.application_status = 'candidate admitted '.

    then

    students update

    the value = 'y '.

    where student_number =: new.student_number;

    end if;

    end;

    /

    Kind regards

    Zlatko

  • Copy the field to another field

    I'm putting in my pdf form to copy part of a field to another field. For example, the user will enter ' London 10000 "(10000 étant le code postal) in field 1 and I want to only copy the word London in field 2". my code does not work

    var a = this.getField ("First_field");

    index = one.indexOf("");

    var length = one.length;

    If (index! = - 1).

    {

    a = one.substring (index, length);

    }

    var two = this.getField ("Second_field");

    two = one;

    Try this:

    try {}

    var oneVal = this.getField("ZIPCODE").value;

    If (oneVal.contains(""))

    {

    I have = oneVal.indexOf("");

    var l = ((oneVal.length - i));

    var twoVal = oneVal;

    i = i + 1;

    twoVal = twoVal.substring (i, (oneVal.length));

    oneVal = oneVal.substring(0,i-1);

    {if (IsNaN (oneVal))}

    this.getField("CITY").value = oneVal;

    } else {}

    this.getField("CITY").value = twoVal;

    }

    App.Alert ('oneVal =' + oneVal);

    } else {}

    {if (IsNaN (oneVal))}

    this.getField("CITY").value = oneVal;

    } else {}

    };

    };

    } catch (e) {}

    {if (IsNaN (oneVal))}

    this.getField("CITY").value = oneVal;

    } else {}

    };

    };

  • How do I delete an article based on the value of another field


    I have a pdf form that I added to the text fields. My challenge is that of the financial section of the form, if the value of a specific field is empty or null, I blank block of signature financial review.  I've been trying to find a way to cover the area of signature with a white box or have a text box with signature block text appear or disappear depending on whether the value is zero or empty.

    If seen many answers on how to make the field itself disappear based on value, but I did find something that causes another field or shape appear or disappear depending on the value of another field.

    Please try the following script,

    var signid = true;

    If (this.getField("finan").value! = 0) signid = true;

    of another signid = false;

    If (SignID) this.getField("signaturefield").display = display.visible;

    else this.getField("signaturefield").display = display.hidden;

    Please let me know if it solves the problem.

  • Drop-down field - when some entries are selected are unavailable another field for data entry

    Hi all

    A sorry again, I am very new to forms and have another question. I have a drop down list which list by selecting certain values I need an another field will not be available if the user can enter data.

    Hopefully this example is logical:

    Drop-down list Champ %
    Outdoor

    Not allowed to enter data

    Previous

    Not allowed to enter data

    Interior

    Not allowed to enter data

    Cotton

    Allowed to enter data

    Wool

    Allowed to enter data

    If someone could give me some examples that would be a great help.

    Thank you very much

    Adam Sadler

    Here is a script that you can use for the validation script custom from the drop-down list. It resets the value of the text box, whenever a change is made to the drop-down list. You can get rid of the line doing it, if you do not want to. Change "text1" in the code to match the name of a text field that you are using.

    Validate a custom for picklist script

    (function () {}

    Get the selected value

    v var = event.value;

    Set up an object to associate status items text box read-only

    var f_state = {}

    'Outside': true,

    'Back': true,

    'Interiors': true,

    'Cotton': false,

    'Wool': false

    };

    Get a reference to the text field

    var f = getField ("text1");

    Clear the text field

    f.Value = "";

    Set the State of read-only text box based on what is selected

    If (v f_state) {}

    f.ReadOnly = f_state [v];

    }

    })();

  • How to make a script that runs only if another field's value

    I have a field in the sales tax in my form

    I do not charge the sales tax in TX, so when they choose the TX State on this field. I want to implement the sales tax.


    I am looking for how exactly that and am not having any luck.

    If it's for a calculated field, you can use a JavaScript custom script to do this, something along the lines of:

    // Calculate script for text field
    (function () {
    
        // Get the value of the State field
        var state = getField("State").value;
    
        // Get the subtotal
        vat total = getField("SubTotal").value;
    
        // Set the tax rate
        var taxRateTX = 0.0825  // 8.25%
    
        // Calculate the tax if Texas
        if (state === "TX") {
            event.value = util.printf("%.2f", total * taxRateTX);
        } else {
            event.value = "";
        }
    
    })();
    

    Change the field names in the code to match your form. I'm assuming that the State is selected in a combo box (dropdown) and it gives a value of "TX" when Texas is selected. Copy the following code rounds up to the nearest cent (assuming that subtotal is in dollars) which maybe aren't correct.

  • How to add a condition to this statement.

    Hi friends,

    I have a requirement of the customer.

    Let me explain the scenario.

    I have a table, which contains some employees say 1, 2,3,4.


    So I wrote a query so that it...

    Select * from where a trunc (sysdate) between effective_start_date and effective_end_date person_id =: p_person_id;

    in this statement, I would like to add a condition more say

    If person_id in (1,2,3,4) then
    p_person_id: = null;
    on the other
    p_person_id = person_id;

    the addition of this condition in mysql statement...

    can someone help me with this...

    Thanks in advance.

    Hello

    Looks like that (no data, not yet tested)

    select * from A
     where trunc(sysdate) between effective_start_date and effective_end_date
       and person_id = CASE
                          WHEN NOT :p_person_id in (1,2,3,4)
                          THEN :p_person_id
                          ELSE person_id
                       END;
    

    Concerning
    Peter

  • Replace null with another field field

    DW CS3 - ASP

    Is it possible to use VBScript to check and replace a field with another field null in the cell of the table of the region a repeat?  I had very little experience with VBScript.  I did experiences but cannot get anything to work yet.

    Not all pets have a name, but all pets have a code.  If the petname field is null, so I want to replace it with petcode.  Is - it closer?

    < %

    If (rs_pets. Fields.Item ("petname"). Value) = IsNull Then

    Replace (rs_pets. Fields.Item ("petname"). (Value), (rs_pets. Fields.Item ("petcode"). Value)

    End If

    % >

    Post edited by: christinett

    > Is this closer?

    Sort of. Test you NULL values by using the IsNull function. The function takes the value of the recordset as a parameter. In addition, you would not use the function replace. Replace is good to replace a portion of a string.

    <>

    var petID

    If IsNull ((rs_pets. Fields.Item ("petname"). (Value)) Then

    petID = (rs_pets. Fields.Item ("petcode"). Value)

    ELSE

    PetID = (rs_pets. Fields.Item ("petname"). Value)

    End If

    %>

    Or, since you will eventually the output value, you don't need the variable, just output the correct value (petname or petcode) using response.write in the appropriate location.

    <%

    Si IsNull ((rs_pets. Fields.Item("petname"). Value)) Then

    response.write (rs_pets. Fields.Item("petcode"). Valeur)

    ELSE

    response.write (rs_pets. Fields.Item("petname"). Valeur)

    End If

    %>

Maybe you are looking for

  • copy and paste volume too low noon

    Hello I am a new user to Logic Pro X I recorded audio and midi in a song tracks, when I copied the first verse and stuck on the second verse, the volume of the second stanza is lower than the original one.  How to fix this? Thank you!

  • How can I prevent the Satellite to sleep when the lid is closed?

    Hello I connected my Toshiba with an external HDMI monitor.The problem is that when I close the lid (I chose the monitors in dual options) instead of sending output to the screen external, portable sleeps. How can I stop the laptop to sleep when the

  • Replication Volumes with SQL databases

    Hi all I'm looking to replicate our environment for DR purposes. Us run on VMWare and SQL Server running on multiple servers. I need to replicate the primary equallogic volumes to secondary equallogic. Is there a way to do this to get compatible appl

  • How to fix Movie Maker?

    How to fix Movie Maker? He repeat that there is a problem and doesn't close. It seems impossible to try to get any assistance with this. It is said there is a problem and is going to close, and that's all. Good luck getting any help from Microsoft. I

  • How to create the custom using Javascripts in PLM for Agile process validator

    I have already created customized using ASP.Net validators. But now I need to create custom using Javascript validator.Please provide me the details1. how to create custom validator and where to create?2 provide me with code samples for custom valida