Copy link to clipboard
Copied
Looking for a way to keep a set of fields inactive (not fillable, read-only etc) until a single checkbox is checked. I have pretty much an entire page that does not need filled in unless someone would check a box for that option.
Thanks
Use this code as the Mouse Up event of the check-box:
var fields = ["Field1", "Field2", "Field3"];
for (var i in fields) {
var f = this.getField(fields);
if (event.target.value=="Off") {
f.readonly = true;
f.value = f.defaultValue;
} else {
f.readonly = false;
}
}
Adjust the names of the fields in the first line to match those in your file, of course.
Copy link to clipboard
Copied
Use this code as the Mouse Up event of the check-box:
var fields = ["Field1", "Field2", "Field3"];
for (var i in fields) {
var f = this.getField(fields);
if (event.target.value=="Off") {
f.readonly = true;
f.value = f.defaultValue;
} else {
f.readonly = false;
}
}
Adjust the names of the fields in the first line to match those in your file, of course.
Copy link to clipboard
Copied
Can't get that script to work. Any suggestions?
Copy link to clipboard
Copied
I've managed to understand the rest of the code except for one line.
What is
for (var i in fields)
What does the 'i' refer to?
Copy link to clipboard
Copied
Actually I just noticed it does work, but it's doing the opposite. Its only making them inactive when the box is UNchecked.
Copy link to clipboard
Copied
Are you sure you placed it where I indicated?
Copy link to clipboard
Copied
Yes, at least I think so...
Copy link to clipboard
Copied
Does the export value of the checkbox affect the script? Mine is set to YES
Copy link to clipboard
Copied
Sorry, I misunderstood how you wanted it to work.
Simply change line #4 from:
if (event.target.value=="Off") {
to:
if (event.target.value!="Off") {
Copy link to clipboard
Copied
try67...
This script was working till I added some additional field names to it. I'm getting the below error. Can you tell me what I need to do? I appreciate your help!
Copy link to clipboard
Copied
You probably missed a comma or something like that. Post the code as text, not as an image.
Copy link to clipboard
Copied
Sorry. Think I found it. Missed a " mark.
Again, thank you for your assistance. Very helpful