Copy link to clipboard
Copied
Hi everyone. In my form I need all the text boxes ("choice 6' "choice 7" "choice 8" and "choice 9") to be deactivated if the check box ("no excursion") is on. So all the text boxes become empty and readonly. And if you uncheck the check box, they should become available again.
And othervise, if you type anything in any of the text boxes, the check box becomes unavailable.
Copy link to clipboard
Copied
In one of text fields as 'Custom calculation script' use this:
var c7 = this.getField("Choice 7");
var c8 = this.getField("Choice 8");
var c9 = this.getField("Choice 9");
var c10 = this.getField("Choice 10");
var chk = this.getField("No excursion 2");
c7.readonly = chk.valueAsString == "Off" ? false : true;
c8.readonly = chk.valueAsString == "Off" ? false : true;
c9.readonly = chk.valueAsString == "Off" ? false : true;
c10.readonly = chk.valueAsString == "Off" ? false : true;
chk.readonly = (c7.value||c8.value||c9.value||c10.value) ? true : false;
Copy link to clipboard
Copied
1. You wrote that your fields are named "no excursion", Choice 6,7,8,9 in your photo fields are named "No excursion 2" and choices 7,8,9,10?
2. I don't get your explanation, if checkbox is checked text fields become read only and empty but if any field have text checkbox is unavailable? That doesn't make sense, why setting script in checkbox to empty fields if they have value checkbox can't be checked?
Copy link to clipboard
Copied
Sorry for confusing) I sent the screenshot from the copy of the file. Will try to explain what I mean) there should be only two options for people filling the form: either they are filling the text boxes (choice 7,8,9,10), or they switch on the check box (No excursion 2). So if any of the text boxes are filled, the check box becomes unavailable and otherwise. Hope I didn't make it very confusing.
Copy link to clipboard
Copied
In one of text fields as 'Custom calculation script' use this:
var c7 = this.getField("Choice 7");
var c8 = this.getField("Choice 8");
var c9 = this.getField("Choice 9");
var c10 = this.getField("Choice 10");
var chk = this.getField("No excursion 2");
c7.readonly = chk.valueAsString == "Off" ? false : true;
c8.readonly = chk.valueAsString == "Off" ? false : true;
c9.readonly = chk.valueAsString == "Off" ? false : true;
c10.readonly = chk.valueAsString == "Off" ? false : true;
chk.readonly = (c7.value||c8.value||c9.value||c10.value) ? true : false;
Copy link to clipboard
Copied
OMG! It works! Thank you very much))

