Custom calculation script for checkboxs

Hello,
Can anyone help me out with custom calculation script for this?  I have two mutually exclusive checkboxes that, when checked, I want to populate data into other text fields.
If Checkbox1 is checked:
Company1=Warehouse Alpha
Address1=1234 Any Street
City/State/Zip1= Los Angeles, CA 90020
Contact Name1= Mr. Nice Guy
Phone Number1= 213-854-8565
Email1=[email protected]
If Checkbox2 is checked:
Company2=Warehouse Beta
Address2= 5678 Awesome Blvd.
City/State/Zip2= San Bernardino, CA 96545
Contact Name2= Mr. Handsome
Phone Number2= 909-824-8265
Email2=[email protected]
Thanks,
Bryan

So one has two check boxes and one wants them to be mutually exclusive. Name them the same and change the export value of the field. Try it and observe what happens as you check the different check boxes.
You have described what happens if either box is checked but what happens when a checked box Is unckecked?
One can place scripts in many locations. I would use a mouse up action for both the check boxes, use the same script for both check boxes.
I would assume you are using the following names for the fields to populate:
Company
Address
CityStateZip
ContactName
PhoneNumber
Email
// Mouse up action for both check boxes;
// initial value for the fields:
this.getField("Company"),value = "";
this.getField("CityStateZip"),value = "";
this.getField("ContactName"),value = "";
this.getField("PhoneNumber"),value = "";
this.getField("Email"),value = "";
// test for check box value for selected box;
if(event.value == 1) {
this.getField("Company"),value = "Warehouse Alpha";
this.getField("CityStateZip"),value = "1234 Any Street";
this.getField("ContactName"),value = "Los Angeles, CA 90020";
this.getField("PhoneNumber"),value = "213-854-8565";
this.getField("Email"),value = "[email protected]";
if(event.value == 2) {
this.getField("Company"),value = "Warehouse Beta";
this.getField("CityStateZip"),value = "5678 Awesome Blvd.";
this.getField("ContactName"),value = "San Bernardino, CA 96545";
this.getField("PhoneNumber"),value = "Mr. Handsome";
this.getField("Email"),value = "[email protected]";
// end Mouse up action for both check boxes;

Similar Messages

  • Custom Calculation Script for building in a percentage increase

    Hello all,
       Looking for a custom calculation script that will apply a percentage increase to a default value when the value of another cell goes above certain numbers. Crude example below.
    Y is the cell that the script will be applied to.
    if value of cell X > 10 then value of cell Y = default value * .10 ..... for 10%
    if value of cell X > 20 then value of cell Y = default value * .20...... for 20%
    if value of cell X > 30 then value of cell Y = default value * .30....... for 30%
    Pleaes forgive me. I know my example above is not in true Java form because I really do not know Java that well. Thanks for any help that you all may provide!

    I've inserted the picture above to help. This is a sizing form for pants for a fire department that will be filled out at the department by the firefighter. The manufacturer that makes the pants passes along a 10% upcharge for anyone with a waist 44-50, a 20% upcharge for anyone with a waist 52-54, and a 30% upcharge for anyone with a waist 56-58. The $42.95 in the "Price" cell is the default price for anyone with a waist that does not meet up-charging penalties (Less than a 44 waist). What I am trying to do is if the firefighter plugs in let's say a waist of 50" the "price' cell will update to show an increase of 10%. ($47.24). If he plugs in a waist of 52" the "price" cell will update to show an increase of 20% ($51.54). If he plugs in a waist of 56" the "price" cell will update to show an increase of 30% ($55.83). I hope that makes sense. I know it can be frustrating helping someone that may not know all the ins and outs like a lot of you do so I greatly appreciate your patience and your help!

  • Custom calculation script for a lease (please help)

    I have so little experience with this it isn't funny.  I prior to now have never used javascript.  But Im trying to get my lease form to auto calculate a tenants pro-rate that would be due if they moved in on the middle of the month for example.
    I created the below script and im sure there is a few things or more than a few things wrong with it...can anyone give me some pointers.
    // Custom Calculate script
    (function () {
        // Get the input field values, as strings
        var leasemonth = getField("LeaseBegMonth").valueAsString;
        var leasestartday = getField("LeaseBegDay").valueAsString;   
        var rentamount = getField("MonthlyRent").valueAsString;
        // calculate how many days in the month
        if ( leasemonth=1
                var leasedays = 31
        elseif (leasemonth=2
                var leasedays = 28
        elseif (leasemonth=3
                var leasedays = 31
        elseif (leasemonth=4
                var leasedays = 30
        elseif (leasemonth=5
                var leasedays = 31
        elseif (leasemonth=6
                var leasedays = 30
        elseif (leasemonth=6
                var leasedays = 30
        elseif (leasemonth=7
                var leasedays = 31
        elseif (leasemonth=8
                var leasedays = 31
        elseif (leasemonth=9
                var leasedays = 30
        elseif (leasemonth=10
                var leasedays = 31
        elseif (leasemonth=11
                var leasedays = 30
        elseif (leasemonth=12
                var leasedays = 31
        //CALCULATE HOW MANY DAYS REMAIN
        var daysremain = LeaseBegDay-leasedays   
        //CALCULATE THE PRORATE AND DISPLAY IT
        event.value = (rentamount/leasedays)* daysremain
    Thanks for your help!!

    Thank you thank you thank you!  Here is the revised script with the changes.  about to go plug it in and see if it works.
    // Custom Calculate script
    (function () {
        // Get the input field values
       var leasemonth = Number(this.getField("LeaseBegMonth").valueAsString);
       var leasestartday = Number(this.getField("LeaseBegDay").valueAsString);   
       var rentamount = Number(this.getField("MonthlyRent").valueAsString);
       var leasedays = 0
        // calculate how many days in the month
    if ( leasemonth==1)
           leasedays = 31;
    else if (leasemonth==2)
           leasedays = 28;
    else if ( leasemonth==3)
           leasedays = 31;
    else if (leasemonth==4)
           leasedays = 30;
    else if ( leasemonth==5)
           leasedays = 31;
    else if (leasemonth==6)
           leasedays = 30;
    else if ( leasemonth==7)
           leasedays = 31;
    else if (leasemonth==8)
           leasedays = 31;
    else if ( leasemonth==9)
           leasedays = 30;
    else if (leasemonth==10)
           leasedays = 31;
    else if ( leasemonth==11)
           leasedays = 30;
    else if (leasemonth==12)
           leasedays = 31;
        //CALCULATE HOW MANY DAYS REMAIN
        var daysremain = leasestartday-leasedays   
        //CALCULATE THE PRORATE AND DISPLAY IT
        event.value = (rentamount/leasedays)* daysremain

  • Custom Calculation Script for invoice

    This is very simple therefore very frustrating that it's not working!
    1. I have a "subtotal" field which is the sum of 6 field. That works fine.
    2. I have a first "gst" tax of 5% field coded as:
    var f = this.getField(“subtotal”);
    event.value = f.value * 0.05;
    There's no error, but it doesn't work. The value in that field remains 0.
    3. I also have a second "qst" tax 7.5% that is more complex.
    The 7.5% is on the sum of the "subtotal" and the "gst", coded as:
    var f = this.getField(“subtotal”) + this.getField(“tps”);
    event.value = f.value * 0.075; 
    (Now I'm not sure about that one) I didn't get a error warning but it doesn't work either.
    The value in that field remains 0.
    What seems to wrong in both taxes?

    Now the problem seems to be the second tax (qst 7.5%)
    What it does, it calculates 7.5% of only the subtotal instead of the sum of the subtotal and the gst (first tax).
    And the all the field are at zero, the qst field does not reset itself. Exemple: when all the field shows $0.00 it shows $0.11
    and for some reason it adds up.
    Here is the script you sent me:
    var total = this.getField("subtotal").value + this.getField("tps").value;
    event.value = total * 0.075;

  • Custom Calculation Script for percentages

    Hi everyone,
    can someone help me, I am trying to write a script, but I face some unsatisfactory results
    I upload the form so you can have a look at it:
    http://cjoint.com/?BGrwV2Sq5d2
    he re is the scenario:
    so after selecting the different module code
    the fields: Excellent, Good, Satisfactory and Unsatisfactory have different values (they have a script)
    eg. if Y1H3 is selected, excellent will be at 33.33 % etc...
    but then I would like that when the Grade is selcted (Grade 1, Grade 2 ....) the fields ( MarksRow1, MarksRow2 ...) take the correspondant value of the fields: Excellent, Good, Satisfactory and Unsatisfactory
    I've tried to write for each of the field MarksRow1, MarksRow1 etc...  the following script this but it doesn't work
    (function () {
        var z = getField("Grade 1").value;
    if (z === 0) {
            event.value = "";
    if (z === 3) {
            event.value = getField("Excellent").value;
    if (z === 4) {
            event.value = getField("Good").value;
    if (z === 5) {
            event.value = getField("Satisfactory").value;
    if (z === 6) {
            event.value = getField("Unsatisfactory").value;
    I would like after that to work out the total in the MarksTotal field by adding the value of ( MarksRow1, MarksRow2 ...)
    can you help me please?
    thanks

    hi George,
    thank you for your interest
    I've just realised that I was complety wrong in the differents tests,  there is no 5 and 6 but only 0,1,2,3 and 4
    and now it's working, thanks
    yes for the total, basically after selecting the different grade, it will display a percentage on the marks column fields ( "MarksRow1"- "MarksRow11" )
    I would like to add this percentages and display the total in the MarksTotale field
    also I would like to leave this field (MarksTotal) empty if nothing has been selected
    I've tried to to do this, but there is a zero when nothing has been selected and it doesn't display the % sign next the total
    here is the form: http://cjoint.com/?BGstXulF9PX

  • Custom Calculation Script for If, If Else

    I have a field named Freq01 where three values can be input; 1, 2, or 3 or it can be left blank. I have another field, Cost01, where I want one of three values to appear, depending upon what number is input in Freq01. Seemed to be a simple enough function!!! I'm using an old version of Acrobat Pro, 6.0.2, Mac OS X, 10.3.9.
    In Excel the function input in cell D11 is:
    =IF((D11=1),3200,(IF(D11=2,3000,(IF(D11=3,2700,0)))))
    And I think the JavaScript code would be:
    I've been trying to figure out how to write it in this AcroJS and I can't get it!!!
    I've tried various combinations of the following, having == instead of = , this.getField("Freq01").value instead of Freq01.value , event.value instead of FullPrice.value , having " " or not...
    if (Freq01.value = "1")
    FullPrice.value = "3200"
    else if
    (Freq01.value = "2")
    FullPrice.value = "3000"
    else if
    (Freq01.value = "3")
    FullPrice.value = "2700"
    Thanks!!!
    rd

    Thanks for the quick response.  I have managed to solve the problem myself. 
    There are 2 states with 12 products each.  Variable to each is selected by combo box.  Product list is fairly stable.  Prices may be updated quarterly.
    Not being a seasoned programmer I may have left a hole or two.  Here is the code with a partial product list. 
    // set variable for State
    var v0 = getField("ComboBox8").valueAsString;
    //set variable for product
    var v1 = getField("ComboBox6").valueAsString;
    if (v0=="GA") {
    // Set up a "Charges" object to associate field value with Charge
    var charge = {
        "Bi-W $150": 15.22,
        "Bi-W $250": 27.84,
        "Bi-W $300": 32.88
    Else
    // state <>”GA”
    var charge = {
        "Bi-W $150": 13.74,
        "Bi-W $250": 25.68,
        "Bi-W $300": 30.72
    // Set default value for this field
    var v2 = "";
    // Get charge from charges object and assign it to this field's value
    if (typeof charge[v1] != "undefined") {
        v2 = charge[v1];
    event.value = v2;

  • 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;

  • How do I create a custom calculation script in a Adobe Acrobat XI form?

    I am building a time sheet.  Inside this time sheet i have two columns.  One column is labeled Hours and the other is labeled Hours Description.
    The fields are labeled under these columns as follows:
    Column Name      Hours          Hours Description
    Field Name          Hours1        HoursDesc1
    The user will input their hours in Numeric Field "Hours1" and will enter an abbreviation in Text Field "HoursDesc1", for example "A" for Administrative Leave or "C" for Compensatory.
    I want to build a script that if Text Field "HoursDesc1" equals "A" or "C" then display Numeric Field "Hours1", else equal 0.  If they enter anything other than "A" or "C", the result will be zero.
    Please help.
    Thank you.

    Custom calculation code for the text field in question:
    var desc = this.getField("HoursDesc1").value;
    if (desc=="A" || desc=="C")
         event.value = this.getField("Hours1").value;
    else event.value = 0;

  • Need Assistance With Custom Calculation Script

    I need help with a custom calculation script in Acrobat Pro.  I am trying to add the sum of fields A, B, C, D, E, F, and G together with the lesser value of fields H and I.  What would be the script to enter for this result?  Thank you.

    event.value = Number(this.getField("A").value) + Number(this.getField("B").value) + Number(this.getField("C").value) + Number(this.getField("D").value) + Number(this.getField("E").value) + Number(this.getField("F").value) + Number(this.getField("G").value) + Math.min(Number(this.getField("H").value), Number(this.getField("I").value));

  • Help with Custom calculation script in Acrobat 8

    Hi all, I am using acrobat 8 on OS 10.5
    I am trying to add certain fields (numbers) and then subtract another field value to give an end result.
    I don't know anything about Javascript, would anyone be able to help with any info on how I achieve this result? I can only see Add, x and average etc... nothing there for subtraction
    Thanks for any help in advance
    Swen

    This should get you started:
    >if (event) {
    // get values from two text fields
    var a = Number(this.getField('Text1').value);
    var b = Number(this.getField('Text2').value);
    // subtract the values and show it
    this.event.target.value = a - b;
    Place this in a 3d text field, as a Custom Calculation Script.

  • Is it possible to use extensive formulas (e.g. "if" or vlookup functions) in the "Custom Calculation Script"?

    I am working on a form fill PDF converted from MS excel. This is for others to use who don't have MS excel that need to use my spreadsheet.
    1. I would like to know how complex can the formulas be in the custom calculation script in the calculate tab under properties in a cell menu?
    2. Where can I find what formulas will work in the custom calculation script along with the format for those formulas to work correctly (tutorials would help)?
    I have tried writing an "if" function but received and error so I am assuming either functions don't work in the script or there is a different format than standard spreadsheet formats.
    Bruce

    In that case the for loop would be:
        for (var i = 0; i < 8; i += 1) {
            sum += +getField("Total." + i).value;
    So initially, the counter i is equal to zero, so the field name used with the getField method is:
    "Total." + 0, which results in the string "Total.0". With each iteration, the variable i is incremented by 1, so the subsequent field names are the following:
    "Total.1"
    "Total.2"
    "Total.3"
    "Total.4"
    "Total.5"
    "Total.6"
    "Total.7"
    The script gets the value of each field, converts it to a number, and adds the number it to the running sum.

  • How do I create an "if" function in a custom calculation script?

    I need to take a simple "value is the sum of" and make it so if one field is less than 1 then the result of the formula will equal "0".
    For example here is a simple "sum of" script:
    Incent Bns.26, Time Bns.26, Spec Bns.26.
    Now converted to a custom calculation script:
    event.value = ((this.getField("Time Bns.26").value) + (this.getField("Incent Bns.26").value)) + (this.getField("Spec Bns.26").value);
    Where Time Bns is calculated by looking at another field Hours26 using a special formula to calculate the bonus.
    I would like to add something like an "if" function to the script so that if the Hours26 field is less than 1 then the output of the script will equal "0".
    I tried this already:
    var rank = this.getField("Hours26").value
    var value = 0
    if (rank < 1) {
      value = 0
    else  (rank > 0) {
       value = ((this.getField("Time Bns.26").value) + (this.getField("Incent Bns.26").value)) + (this.getField("Spec Bns.26").value);
    event.value = value
    But get the error: SyntaxError : missing ; before statement 7 at line 8:
    Thanks ahead of time for any help.
    Bruce

    Try this:
    var rank = this.getField("Hours26").value;
    var value = 0;
    if (rank < 1) {
      value = 0;
    } else {
       value = ((this.getField("Time Bns.26").value) + (this.getField("Incent Bns.26").value)) + (this.getField("Spec Bns.26").value);
    event.value = value;

  • Custom Calculation Script Help Needed

    I need to make a script that Sums a column of fields based on whether or not information found in another column of fields is the same or specific text. Please see below screenshot of what I would like it to do.
    I would like a Sum of all Amounts that have the Code A...

    You can use this script as the custom calculation script of "SumOfA":
    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 easily adjust it for the other field as well.

  • Custom Calculation Script Question

    I'm flying blind here, I know nothing about this stuff. I just need something i can copy and paste into the "custom calculation script" box.
    I'm working on making a character sheet for star wars saga edition auto calculate. The only thing I have left before it is completely done is one last calculating field. However, I have no clue how to do it.
    What it needs to do is take the value from one field (user entered info) and then divide it by 2, always rounding down.
    The field the user enters a number in is named "Level" and the field that needs to display that number is named "1/2lvl".

    If no one answers here you can try the Acrobat Scripting forum.

  • Custom calculation script not working

    Hi...
    I've been looking at the samples and searching but have yet to make my custom calculation script work.  The bottom line is that I want one field to be blanked out if another is populated.
    My script currently looks like this:
    event.value = (getField("List_B1") + '').length > 0 ? '' : getField("List_A1");
    I've also tried
    event.value = (getField("List_B1").value + '').length > 0 ? '' : getField("List_A1").value;
    Neither result in List_A1 being empty when List_B1 has something in it.
    Anyone see something I'm missing?
    Thanks
    Mark

    The fields are being processed in programmatically.  The request came in that when we save the form values as a pdf that they don't want any List A value to show if List B has a value set.  So to give an example the inputs would be
    List A : foo
    List B : bar
    List C : baz
    What I'm trying to do with the custom calculation is to have the output pdf be
    List A:
    List B: bar
    List C: baz
    at least that's what my script was aiming for, but what's coming out is
    List A : foo
    List B : bar
    List C : baz
    Come to think about it, it probably has to do with the order with which the fields are being set and the expression fires.  In other words, it could be that when List A is set, List B hasn't been set yet, so the expression's a no-op...
    Thanks
    Mark

Maybe you are looking for

  • Is there a known issue with Mavericks and Outlook 2011 printing?

    Title says it all. I was reading up on past forums both Apple/Microsoft when 10.6.8 messed up Outlook printing, was wondering if anyone else is having a similar issue. I am currently on 10.9.2. I began noticing the issues after updating to 10.9.2. To

  • RFC Error while posting   GR

    Runtime Errors        MESSAGE_TYPE_X Date and Time          01.07.2009 14:25:17 |Short text                                                                                        | |    The current application triggered a termination with a short dum

  • Credit memo request with currency conversion to EURO

    I have a requirement in which i need to create a Credit Memo Request for the newly created sales organisation using the old billing document number created for old sales organisation.New sales org will have its currency changed to EURO.I referred to

  • How can we claim 100% cen credit in first year of  imported  CAP Goods

    We are taking cenvat credit of Additional Excise Duty on imported goods, 50% in first year and balance 50% in next year. However 100% cenvat credit can be claimed in the first year (when we receive the goods). How can we amend the same in SAP, so tha

  • Use of alternative field label in TMW

    Hi, I'm using a customer-specific field under IMG>Time Management>Time Manager's Workplace >Screen Areas>Time Data>Define Table for Time Events and I want to change the field description displayed in TMW under the Time Events tab. I've tried to use t