Skip to main content
Participating Frequently
January 29, 2025
Question

Word generated from number range

  • January 29, 2025
  • 2 replies
  • 1129 views

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!! 

    2 replies

    Nesa Nurani
    Community Expert
    Community Expert
    January 29, 2025

    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.

    Participating Frequently
    January 29, 2025

    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?

     

    Nesa Nurani
    Community Expert
    Community Expert
    January 30, 2025

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

    kglad
    Community Expert
    Community Expert
    January 29, 2025

    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">