Skip to main content
Participating Frequently
Jan 29, 2025 3:08 AM UTC
Question

Word generated from number range

I'm needing a phrase to be generated from a specific value range generated from a separate field within the same pdf form.  For example if the associated field (call it "Field X") generates a number between or including:

34-57 the phrase generated is "Income with Capital Preservation"

58-83 the phrase generated is "Income with Moderate Growth"

84-99 the phrase generated is "Growth with Income"

100-114 the phrase generated is "Growth"

115-125 the phrase generated is "Aggressive Growth"

 

Thank you in advance for your help!! 

    12 replies

    Nesa Nurani
    Community Expert
    Community Expert
    Jan 29, 2025 5:13 AM UTC

    Use this as custom calculation script of a field where you wish to show text:

    var fieldX = Number(this.getField("Field X").valueAsString);
    var phrase = "";
    
    if (fieldX >= 34 && fieldX <= 57) {
     phrase = "Income with Capital Preservation";} 
    else if (fieldX >= 58 && fieldX <= 83) {
     phrase = "Income with Moderate Growth";} 
    else if (fieldX >= 84 && fieldX <= 99) {
     phrase = "Growth with Income";} 
    else if (fieldX >= 100 && fieldX <= 114) {
     phrase = "Growth";} 
    else if (fieldX >= 115 && fieldX <= 125) {
     phrase = "Aggressive Growth";}
    
    event.value = phrase;

    Replace "Field X" with the actual name of the field in which you generate the number.

    Translate
    Participating Frequently
    Jan 29, 2025 7:55 PM UTC

    Hi and thank you so much for your help!

    I input the formula as

    var TOTAL SCORE = Number(this.getField("TOTAL SCORE").valueAsString); var phrase = ""; if (TOTAL SCORE >= 34 && TOTAL SCORE <= 57) { phrase = "Income with Capital Preservation";} else if (TOTAL SCORE >= 58 && TOTAL SCORE <= 83) { phrase = "Income with Moderate Growth";} else if (TOTAL SCORE >= 84 && TOTAL SCORE <= 99) { phrase = "Growth with Income";} else if (TOTAL SCORE >= 100 && TOTAL SCORE <= 114) { phrase = "Growth";} else if (TOTAL SCORE >= 115 && TOTAL SCORE <= 125) { phrase = "Aggressive Growth";} event.value = phrase;

     

    but received the error below.  Can you help me identify what I'm doing wrong?

     

    Translate
    Nesa Nurani
    Community Expert
    Community Expert
    Jan 30, 2025 5:54 AM UTC

    That doesn't look like Acrobat software you are using?

    Translate
    kglad
    Community Expert
    Community Expert
    Jan 29, 2025 3:45 AM UTC

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



    <"moved from using the community">
    Translate