Skip to main content
Participating Frequently
May 6, 2024
Question

Conditional Formatting

  • May 6, 2024
  • 3 replies
  • 2225 views

I have a form that asks whether an item was budgeted and then the price of the item.  This form is to be emailed to certain people based on whether the item was budgeted and also the price.  I have buttons set up that runs the script of who to email the form to when clicked on.  I want to be able to have a button called 'Submit to COO' appear if the item was not budgeted, or if the item was budgeted but the price is $50,000 or more.  If this is not the case, then I want a button called 'Submit to CFO' if the item was budgeted and the price is under $50,000.  Is this possible to do?  If so, please provide the steps on how to make it work.

 

Thanks.

    This topic has been closed for replies.

    3 replies

    Participating Frequently
    May 6, 2024

    This is the JavaScript I currently have.  It works correctly when the item was not budgeted.  However, I can't get it to work correctly when the item was budgeted and the price was less than $50,000.00 or when the item was budgeted and the price was more than $50,000.00.  What am I doing wrong?

     

    var Q=this.getField("Budgeted?");
    var R=this.getField ("ActutalBudget");
    var A=this.getField("Submit to CFO");
    var B=this.getField("Submit to COO");
    if(Q.value==="Yes" && R.value<"50,000.00"){
    A.hidden=false;
    B.hidden=true;
    }
    if(Q.value==="YES" && R.value>="50,000.00"){
    A.hidden=true;
    B.hidden=false;
    }
    if(Q.value==="No"){
    A.hidden=true;
    B.hidden=false;
    }

     

    try67
    Community Expert
    Community Expert
    May 6, 2024

    Couple of notes:

    - Don't use the hidden property. It was replaced by the display property.

    So replace these lines:

    A.hidden=false;
    B.hidden=true;

    with:

    A.display = display.visible;
    B.display = display.hidden;

    - When comparing to a number you must not put it in quotes, or it will be treated as a string.

    So change this part of the code:

    R.value<"50,000.00"

    With this:

    R.value<50000.00

    - JS is case-sensitive, so "Yes" and "YES" are not the same thing.

    - You need to add a condition to your code that deals with the case when neither Yes or No are selected. In that case, the value of the check-box group will be "Off" by default.

    Participating Frequently
    May 7, 2024

    I have made the changes as you mentioned.  I tried to add in the condition when neither Yes or No are selected but it's not working.  Here is what I put:

     

    var Q=this.getField("Budgeted?");
    var R=this.getField ("ActutalBudget");
    var A=this.getField("Submit to CFO");
    var B=this.getField("Submit to COO");
    if(Q.value!=="Off");
    if(Q.value==="Yes" && R.value<50000.00){
    A.display=display.visible;
    B.display=display.hidden;
    }
    if(Q.value==="Yes" && R.value>=50000.00){
    A.display=display.hidden;
    B.display=display.visible;
    }
    if(Q.value==="No"){
    A.display=display.hidden;
    B.display=display.visible;
    }

     

    What did I do wrong?  Sorry, learning as I go with the conditional formatting.

    try67
    Community Expert
    Community Expert
    May 6, 2024

    Is this a check-box, a drop-down field, a text field, or something else?

    Participating Frequently
    May 6, 2024

    The yes or no response for a budgeted item are radio buttons, the price is a text field and the 'Submit to COO' and 'Submit to CFO' are buttons.

    kglad
    Community Expert
    Community Expert
    May 6, 2024

    assuming acrobat...

     

    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">
    Participating Frequently
    May 6, 2024

    Yes, I have Adobe acrobat.

    kglad
    Community Expert
    Community Expert
    May 6, 2024

    good.  your post is in the acrobat forum.