Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
When you want to compare two values use "==", or "===" (without the quotes). The "=" operator is used to assign a value.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Where did you place the code?
Either way, you have to change it, as your current code is not correct.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
How are you hiding/unhiding the "FC Signature" field, exactly?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
The code you posted doesn't hide anything. Setting the field as read-only is not the same as hiding it.
Copy link to clipboard
Copied
Ugh. Sorry sir. I updated my response to include the hiding/ unhiding. I know read only is different than hiding
Copy link to clipboard
Copied
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 == "");
Copy link to clipboard
Copied
Code is triggered from any combination of four radio button sets (8 buttons). The code is already in calculation field.
Copy link to clipboard
Copied
Then use the code I posted instead of the one in your original post (all of it!).
Copy link to clipboard
Copied
If it still doesn't work you'll need to share the actual file (here or privately) for further help.
Copy link to clipboard
Copied
How do I send privately?
Copy link to clipboard
Copied
You can send it to me via [try6767 at gmail.com].
Copy link to clipboard
Copied
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!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now