Skip to main content
stepheng54012748
Known Participant
October 31, 2024
Answered

Is it possible to turn a field off and on based on a check box?

  • October 31, 2024
  • 2 replies
  • 2580 views

I'm wondering if it is possible to write a javascript to turn off another field in a PDF form if a Check Box is checked?  I'm not even close on this one below.  I'm trying to figure out if someone checks check box cb144 then if will rendor another field 6a unfillable.  If it's unchecked then it can be filled in.  Is this possible?  Thank you again if anyone has any ideas on how to code this one.

 

var theField = this.getField("cb144");
var theValue = theField.value;

if (theValue == "Resident") {
this.getField("6a").value= "";
}
else {
this.getField("6a").value= "";
}

This topic has been closed for replies.
Correct answer PDF Automation Station

Part 17a4b is part of the other 2 choices.  


if(this.getField("17a4a").value=="Yes" || this.getField("a17a4c").value=="Yes" || this.getField("a17a4b").value=="Yes")
{event.target.readonly=true}
else
{event.target.readonly=false}

2 replies

ls_rbls
Community Expert
Community Expert
October 31, 2024

Hi @stepheng54012748 , @PDF Automation Station 

 

I was also testing this as a Mouse Up event script executed from the checkbox widget:

 

(event.target.value !== "Off") ? this.getField("6a").readonly = true : this.getField("6a").readonly = false 

 

 

PDF Automation Station
Community Expert
Community Expert
October 31, 2024

Assuming the export value of cb144 is "Resident", enter the following custom calculation script in field 6a:

if(this.getField("cb144").value=="Resident")

{event.target.readonly=true}

else

{event.target.readonly=false}

stepheng54012748
Known Participant
October 31, 2024

Wow .  This works great!  I really appreciate it.   You are awesome.