Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Locking/ Unlocking Field (based on radio buttons) when Signature Field is Hidden/ Visible

Participant ,
Jun 04, 2025 Jun 04, 2025

The following code is in a calculation field.  I have a separate button that hides/ unhides the FC signature field.

 

The first part works when the FC signature field is hidden but the second part when the FC signature field is visible doesn't work for some reason and I cannot figure out why.

 

Goal is to lock the BO signature field if the CH signature field is signed (and FC signature field is unsigned) and the FC signature field is visible.  In other words, if we unhide the FC signature field after the CH signature field is signed (and FC signature field is unsigned), lock the BO signature field.

 

 

    if(getField("FC Signature").display = display.hidden)
        //when FC sig is hidden, locks BO sig when CH sig is empty/ unlocks BO sig when CH sig is signed
            if(getField("CH Signature").value == "") 
                getField("BO Signature").readonly = true

            else 
                getField("BO Signature").readonly = false

    else
        //when FC sig is visible, locks BO sig when CH sig is signed and FC sig is empty
            if(getField("CH Signature").value != "" && getField("FC Signature").value == "") 
                getField("BO Signature").readonly = true

 

TOPICS
Create PDFs , How to , JavaScript , Modern Acrobat , PDF , PDF forms
515
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2025 Jun 04, 2025

When you want to compare two values use "==", or "===" (without the quotes). The "=" operator is used to assign a value.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 04, 2025 Jun 04, 2025

Yes sir.  I tried that but the opposite happens.  When FC sig is visible,  it unlocks BO sig when CH sig is signed.  And when FC sig is hidden,  it locks BO sig when CH sig is signed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2025 Jun 04, 2025

Where did you place the code?

Either way, you have to change it, as your current code is not correct.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 04, 2025 Jun 04, 2025

I placed it in the calculation field of another form field.  I can't figure out what to change.  I have spent like two days on this trying to correct every which combination and I am still stuck.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2025 Jun 04, 2025

How are you hiding/unhiding the "FC Signature" field, exactly?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 04, 2025 Jun 04, 2025

Funny you ask....I am hiding it this way:

    
if(   
     (
        (
        (((this.getField("AssetBox").value == "Choice1" || this.getField("AssetBox").value == "Choice2") && this.getField("TotalBox").value == "Choice2") || 
        (this.getField("AssetBox").value == "Choice2" && this.getField("TotalBox").value == "Choice1") || this.getField("AssetBox").value == "Off")
        )
        
        ||

        (
            ((this.getField("LikeBox").value == "Choice1" || this.getField("LikeBox").value == "Choice2") 
            &&
            ((this.getField("TotalBox").value == "Choice2" && this.getField("UnitBox").value == "Choice2") || (this.getField("TotalBox").value == "Choice2" && this.getField("UnitBox").value == "Choice1") || (this.getField("TotalBox").value == "Choice1" && this.getField("UnitBox").value == "Choice2"))
    
            ||
    
            (this.getField("LikeBox").value == "Choice2" && this.getField("TotalBox").value == "Choice1" && this.getField("UnitBox").value == "Choice1") || this.getField("LikeBox").value == "Off")
        )
    )
)

        this.getField("FC Signature").display = display.hidden;

 

and unhiding it this way:

if(
    (
    (this.getField("AssetBox").value == "Choice1" && this.getField("TotalBox").value == "Choice1")
    
    ||

    (this.getField("LikeBox").value == "Choice1" && this.getField("TotalBox").value == "Choice1" && this.getField("UnitBox").value == "Choice1")
    )
)

        this.getField("FC Signature").display = display.visible;

 

I have four sets of radio buttons with complex combinations so I figured I would go the simpler route and evaluate the display property. 

 

As we were messaging back and forth, I actually substituted the original code

if(
    (   
        (
        (((this.getField("AssetBox").value == "Choice1" || this.getField("AssetBox").value == "Choice2") && this.getField("TotalBox").value == "Choice2") || 
        (this.getField("AssetBox").value == "Choice2" && this.getField("TotalBox").value == "Choice1") || this.getField("AssetBox").value == "Off")
        )
        
        ||

        (
            ((this.getField("LikeBox").value == "Choice1" || this.getField("LikeBox").value == "Choice2") 
            &&
            ((this.getField("TotalBox").value == "Choice2" && this.getField("UnitBox").value == "Choice2") || (this.getField("TotalBox").value == "Choice2" && this.getField("UnitBox").value == "Choice1") || (this.getField("TotalBox").value == "Choice1" && this.getField("UnitBox").value == "Choice2"))
    
            ||
    
            (this.getField("LikeBox").value == "Choice2" && this.getField("TotalBox").value == "Choice1" && this.getField("UnitBox").value == "Choice1") || this.getField("LikeBox").value == "Off")
        )
    )

)
        //when FC sig is hidden, locks BO sig when CH sig is empty/ unlocks BO sig when CH sig is signed
            if(getField("CH Signature").value == "") 
                getField("BO Signature").readonly = true

            else
                getField("BO Signature").readonly = false

    else
        //when FC sig is visible, locks BO sig when CH sig is signed and FC sig is empty
            if(getField("CH Signature").value != "" && getField("FC Signature").value == "") 
                getField("BO Signature").readonly = true

 

and it works only if both conditions are met for unhiding versus either or which still leaves me just short of the solution.  My brain is just fried at this point.

 

Hope I didn't lose you! lol

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2025 Jun 04, 2025

The code you posted doesn't hide anything. Setting the field as read-only is not the same as hiding it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 04, 2025 Jun 04, 2025

Ugh.  Sorry sir.  I updated my response to include the hiding/ unhiding.  I know read only is different than hiding

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2025 Jun 04, 2025

OK, then assuming that code is not executed from a button (which will not trigger the calculation events), this should do when you've described:

 

this.getField("BO Signature").readonly = (this.getField("FC Signature").display == display.hidden && this.getField("CH Signature").value == "");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 04, 2025 Jun 04, 2025

Code is triggered from any combination of four radio button sets (8 buttons).  The code is already in calculation field.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2025 Jun 04, 2025

Then use the code I posted instead of the one in your original post (all of it!).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2025 Jun 04, 2025

If it still doesn't work you'll need to share the actual file (here or privately) for further help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 04, 2025 Jun 04, 2025

How do I send privately?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2025 Jun 05, 2025

You can send it to me via [try6767 at gmail.com].

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 06, 2025 Jun 06, 2025
LATEST

I was able to figure it out using the original code above with the four radio buttons (AssetBox, LikeBox, TotalBox, UnitBox).  For whatever reason, simply using the hidden/ visible properties as a condition was not as effective...don't know why...so weird but oh well!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines