JavaScript in a text field to show/hide a field calculated

Thanks for your help. Here's the situation. I created a form with text, number fields (currency) fields and calculated fields. Fields display calculated the monetary symbol (even when there is nothing to calculate) and this is a problem for our users who want to just print the form and fill it out by hand (because the monetary symbols get in the way.). So I wanted to write a script would make it calculated fields hidden unless there is actually something is entered in the first text field (EmpID). That's what I came with (TotalCompensationRow1 is a calculated field.):

var TotalCompensationRow1Fld = this.getField ("TotalCompensationRow1")

If {(event.value)
TotalCompensationRow1Fld. display = display.hidden
}

else {}
TotalCompensationRow1Fld. display = display.visible
}

Somehow, I think I make it much more difficult that it should be. Thanks again for your help.

Another approach would be to change the formatting of the displayed field. When using a percentage or a monetary symbol, can not suppress the display of the "0.00"or "0.00%". " But if one use the number format with no currency symbol, you can remove the display "0.00".

Validation of currency format:

var nDec = 2; set the number of decimal places; number & percent;

var sepStyle = 0; style of thousands separator; number & percent;

var negStyle = 0; negative style; number only;

var currStyle =""; always null; number only;

var strCurrency = ""; currency symbol; number only;

var strCurrencyCurrency = ' $'; currency symbol; number with the currency symbol;

var bCurrencyPrepend = false; prefix of currency; number only;

var bPercentPrepend = false; percentage of prefix; percent only;

Console.println (Event.value);

If (event.value == 0 | event.value == "") {}

Event.Value = "";

AFNumber_Format (nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend);

} else {}

bCurrencyPrepend = true;

AFNumber_Format (nDec, sepStyle, negStyle, currStyle, strCurrencyCurrency, bCurrencyPrepend);

}

Validation of the percentage format:

nDec var = 1; set the number of decimal places; number & percent;
var sepStyle = 0; style of thousands separator; number & percent;
var negStyle = 0; negative style; number only;
var currStyle =""; always null; number only;
var strCurrency = ""; currency symbol; number only;

var strCurrencyCurrency = ' $'; currency symbol / / number with currency symbol;
var bCurrencyPrepend = false; prefix of currency; number only;
var bPercentPrepend = false; percentage of prefix; percent only;
If (event.value == 0 | event.value == "") {}
Event.Value = "";
AFNumber_Format (nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend);
} else {}
AFPercent_Format (nDec, sepStyle, bPercentPrepend);
}

Tags: Acrobat

Similar Questions

  • Need help: the value of checkbox auto fill in the field of text and text field calculation

    Noob on this site.

    So I currently have a form to fill out, asking me if certain actions are possible. I am fairly new to the technical aspects of livecycle so real with me if you can.

    I have a series of 4 boxes with values assigned to each. Below the 4 boxes, I have a 4 additional text fields at least one fields relate to one of the 4 possible box selections.

    OK, here we are so spare with me:

    Is it possible to link the 4 boxes in the text field below, i.e. When you click on one of the 4 boxes, the included value apart from that the check box automatically to fill the text field below about 4 possible selections?

    Second question: How can I change the text field automatically calculate numeric values with the 4th text field ending by the result of the calculation?

    example below

    Accounting by year
    Checkbox
    100
    120
    144
    160


    Text fields
    Comments
    Holiday balance

    Less expenses to pay for a year
    -> That's where I want the box above for AutoFill when selected above
    ( = )
    I want this field to subtract the 1st class area and 2nd givign me total

    Eligible to convert hours:

    50% of the balance above


    I want this field to take the total field above and divide by 2

    Can anyone help please. Thank you

    If I'm working on the fact that the four items of the table is called:

    1. currentBalance
    2. accrual accounting
    3. Balance
    4. eligibleHours

    So if you go on the 3rd field (balance) and have the following text in the calculate (JavaScript) event:

    this.rawValue = currentBalance.rawValue - accrual.rawValue;

    In the area of 4th (eligibleHours) and have the following text in the calculate (JavaScript) event:

    this.rawValue = balance.rawValue / 2;

    Niall

  • show or hide text fields based on another text field value

    Hi, I have 3 text fields totals. by default, first text field is visible & other hidden two. what I want to do is if enter all the values in the first text box, other two text fields should automatically visible. Likewise, if I remove the value in the first text box, and then two other fields should automatically hide again. so thanks for giving me a java script for that. also I need javascript for hidden text fields. This script should check the values in the first field work and text (visible or hide). Thanks in advance...

    As the custom field the validation script enter this code (of course, set the names of the other fields as required):

    if (event.value=="") {
        this.getField("Field2").display = display.hidden;
        this.getField("Field3").display = display.hidden;
    } else {
        this.getField("Field2").display = display.visible;
        this.getField("Field3").display = display.visible;
    }
    
  • When a box is checked, fill a text field with a value

    I don't know that it's simple; However, I am very new to acrobat and javascript.

    Here's what I want to do:

    I have a checkbox field and a text field. If the checkbox is turned "on" I want to fill the text field with a specific numeric value.  If she isn't 'unchecked' there is not value or value 0.  Any help is appreciated.

    Enter this code in the custom of your text field calculation script:

    This.getField("CheckBox1").value = Event.Value == "Off"? 0: 1234;

  • in Acrobat DC - I would like to change the font of a strikethrough text field after that I have check the box next to it.

    I work on a document in Acrobat DC and want to be able to use checkboxes as a checklist. Once the box is checked, I want the police in the text box the box is associated with having a police barred .

    Is this something that needs javascript?

    Textfield name is 4MedHistoryMedication1 , and there already Calibri font type.

    The box is named 4MedHistoryMed_1_RXonFile

    When the 4MedHistoryMed_1_RXonFile checkbox is checked, then the text in 4MedHistoryMedication1 will be Calibri ; So any content text already typed into this text field will get the police barred.

    Don't forget that I'm not familiar with Javascript.

    It will take JavaScript and the text field must be put in place to allow rich text formatting. You will need to set the value by using span in order to set the bar. Here is a sample script for the script of mouse upward to a check box that should help you get started:

    Script mouse upwards to the box

    (function () {}

    Set a Boolean value that indicates whether to set the property for each span made out

    which depends on the State of this check box

    var bStrikethrough = event.target.value! == 'Off '.

    Get a reference to the text field

    var f = getField ("4MedHistoryMedication1");

    Get the value of the text spans tabular field that represents the rich text value

    var aRV_spans = f.richValue;

    Set the property for each span made out

    for (var i = 0; i)< arv_spans.length;="" i="" +="1)">

    aRV_spans [i] .strikethrough = bStrikethrough;

    }

    Update the value of the text field

    f.richValue = aRV_spans;

    })();

    More info is Acrobat JavaScript reference.

  • How you grey on an option button if a text field is blank in Adobe Acrobat Pro XI?

    How you grey on an option button if a text field is blank in Adobe Acrobat Pro XI?

    So, what I'm doing:

    (     )   | TEXT FIELD.

    (     )   | TEXT FIELD.

    (     )   |                  |

    (     )   | TEXT FIELD.

    I have a radio button :)

    and a text field. TEXT FIELD.

    The third text field is empty, and I would like to than radio button gray (the user cannot click on it) because the text field is empty. Is it possible to get? I guess I'll have to use javascript, but what would the code and must it be entered in the javascript for the text field editor or the radio button?

    Thanks in advance guys

    Enter this code in the custom text box validation script:

    this.getField("RadioButtonName").readonly = (event.value == "");

  • develop/tab Show / Hide regions

    Try to do a dynamic button that could expand all show and hide regions on the page once click. and tabs them when you click New.

    I was wondering if anyone knows how to do this... ?

    Published by: PandaOracle on 8 June 2012 10:49

    Just use javascript to toggle below code (all show/hide all)

    $('.t1HideandShowRegionLink').children('img').click();
    
  • Select the text in a text field when selected on?

    I would like to change my form so that when you click on a text field (per a user in adobe reader) all the text in the field is selected.  This is the behavior by default when you tab through the form, but I want to do even if the text field is just clicked.

    As part of the same question, I would like to know if there is a script that can be used to create entries in the keyboard?  If there is another way to do it would be better, but it might be useful if I could program the form so that when you click on a text field the keys 'Ctrl' and 'A' are used to highlight and 'Ctrl' and 'c' to copy the text, because it would be the main purpose of the form is copy and paste to a customers Web site.

    The first part of your question can be made by putting the following code in the click event (JavaScript) of a text field:

    xfa.host.setFocus (null);

    xfa.host.setFocus (this);

  • refer to his car in custom text field calc

    I have a custom for a text field calculation, but I would like to know if it is possible to set the field itself as a variable without having to refer to the field name.  EITHER this.getField ("name") works, but I want to use this same script a number other text fields and do not want to customize each one.

    To get a reference to the field to which the script is attached, the field object is the value of event.target, so the code could be simplified as follows:

    // Custom Calculate script
    event.target.readonly = getField("Set 1").value === "Off" ? true : false;
    

    I changed to the analysis with a value of "Off", because the script didn't need to know what is the value of exports from the box. A deselected checkbox will have a value of "Off". This makes the script more generic.

  • Captivate: Using Javascript to show/hide captions text

    Hello

    I want to show/hide a legend of text using javascript. I can't find the way to do it with advanced actions. I don't know if it's because it belongs to a question slide in a pool. Anyone know if this is possible and how this can be done?

    There is nothing wrong with your English - no need to apologize :-)

    I just tested it. Seems to work for me to create a tip action that will show my custom legend if I set a variable of personalized tour. Rather than xplain, I have attached a word with some screen shots doc and an example of file CPTX. File is Captivate 5, but even should work in 5.5

    Steve

  • Show/hide text field

    Hello

    I have the Group of option buttons, five choices, and by choosing No. 5, I want a text field become visible.

    Someone at - it an idea how to make this happen?

    Kirstine

    You will write the code on the change event of the RadioButtonList method (look in the hierarchy) where radio buttons are grouped. The group object will hold the value currently set for the RadioButtonList method. You can test to see if the group is set to 5 while you bring up your field. Make sure that each RadioButton has a unique value when it is turned on. Something like this:

    If (this.rawValue == 5) {}

    FieldName.Presence = "visible".

    } else {}

    FieldName.Presence = 'invisible '.

    }

    Paul

  • Show/Hide function checkbox fields

    A common question that I know, but I'm having a problem with field labels.

    The PDF form has been created with FormsCentral and then edited locally with XI of Acrobat (version 11.0.10) on Windows 7 Pro.

    The PDF file has a check box to allow the user to enter a separate shipping address. In the properties of the check box, the Actions tab, I have the mouse upward as the trigger and following JavaScript code.

    var nHide = event.target.isBoxChecked (0)? display.visible:display.hidden;

    this.getField("SHIPPING_ADDRESS").display = nHide;

    this.getField("CITY_2").display = nHide;

    this.getField("STATE_/_PROVINCE_2").display = nHide;

    It works well, however, field labels remain visible in the PDF, regardless of the State of the visible / hidden.

    How to hide the labels of field and the fields themselves when the checkbox is unchecked?

    Thank you

    BW200

    Assuming that the labels are static text that you cannot hide directly. What

    You can do however, is to place white fields above them and then show

    These fields when you want to hide the text below and hide them when

    you want the text to be visible.

  • Hide an option button when a text field is filled?

    Hello

    I was wondering if someone could help with this.  I want to set up a form for a radio button is disabled when a field is filled in.

    I tried a simple Action (show/hide a field), but I would like the user to be able to change your mind - so if they begin to enter the field of information and then delete, they can always select Yes or not later.

    I hope I'm explaining this well.  I read through the discussions and the acticle of Thom Parker, but I am sorry to say that because I don't know Javascript, it is completely over my head.

    Any help would be greatly appreciated!

    Thank you.

    If you want the buttons radio is available that when the text field is empty and inactive when the text field is not empty, you can use the validation script customized for the text field:

    // Custom Validate script
    (function () {
    
        // Reset the radio button field
        var f = getField("rb1");
        resetForm([f.name]);
    
        // Set the readonly property based on this field's value
        f.readonly = event.value;
    
    })();
    

    Replace "rb1' with the actual name of the option buttons.

  • show/hide fields with percentages

    I'm trying to find a script to show/hide a field as a percentage that is located in one of the fields. The script that I usually use to base numbers is:

    var r1 = this.getField ("V1");
    var r2 = this.getField ("V2");

    R1. Hidden = true;
    R2. Hidden = true;

    If (event.value < = "100")
    {
    event.willCommit = true;
    {

    R1. Hidden = false;
    }
    }

    If (event.value > = "101")

    {

    event.willCommit = true;

    {

    R2. Hidden = false;

    }

    }

    So I need basically the same thing again but I need to be field appears if "38.00%" or above is entered. If anything lower then it is entered, I need 2 field is displayed... I can't make it work once the decimals are here.

    Thank you in advance for your help!

    The percentage format is just for display and rounds the value of the current field, the value of the actual field is the decimal number created by the division or entered by the user.

    100% is entered as 1.00 but if the result of a calculation, it could be 99, 5 - 1.4. If you want to compare the calculated value, you may need to round the value of the fields for the same number of decimal places that display area. You should be aware that using the Math.round of JavaScript method may cause an error with numbers rounding floating-point. You can use the util.printf method in Acrobat JavaScript to properly round a field value.

    I also wouldn't quotes on numeric constants.

    var r1 = this.getField ("V1");
    var r2 = this.getField ("V2");
    R1. Hidden = true;
    R2. Hidden = true;

    If (util.printf ("% 1 .2f", event.value))<= 1.00)="">
    R1. Hidden = false;
    }

    If (util.printf ("% 1 .2f", event.value) > = 1.01) {}
    R2. Hidden = false;
    }

  • By assigning a value to a text field not working PHP/javascript?

    I have a site to someone else coded, where a text field does a value that is assigned.

    Both
    Form1.textfield3.value = form1.textfield1.value;
    and
    Form1.textfield3.value = "99";

    not work, and the field is left blank.

    This same code works on Internet Explore (Win and OSX), Safari, Chrome and Opera. It does NOT work on Firefox 8 or 9.01 (Win and OSX) or 3.6.25. He used to work on an older Firefox, we had (unknown version).

    JavaScript is enabled; is there anything else we can check?

    If you check the error in Firefox (Ctrl + Shift + j) Console, you will see "form1 is not defined. This is because Firefox converts automatically form1 in reference to < form = "form1" name >. Instead, you must change the code a bit.

    You can fix the above error starting each function where you refer to form1 with this:

    Form1 = return ["form1"] var;

    However, probably just move the error to the next part of the notation (for example, textfield3). The proper way to refer to the value of a form field named is:

    document. Forms ["Form1"]. Items ["textfield3"]. Value

    or if you have set form1,

    Form1.elements ['textfield3'] .value

    If you have a few changes to make. Not sure if there are shortcuts.

    This forum focuses on the care of the end user. You can find more help web development on the mozillaZine Web Development Council. Separate forum, separate registration.

Maybe you are looking for