Copy link to clipboard
Copied
I have a script for a checkbox that when checked will check other checkboxes at once. It is supposed to check all of the boxes and then make those checkboxes read-only, reverting back again if the original checkbox is then unchecked.
For some reason, the first check box (CheckBoxNA7.1) won't turn to read-only and I can't figure out why! I am only showing a portion of the script as the full script has 6 checkboxes and all the other 5 turns to read-only, just not 7.1 for some reason. Can anybody see what the issue might be?
if(event.target.isBoxChecked(0)){
this.getField("CheckBoxNA7.1").checkThisBox(0,true);
this.getField("CheckBoxNA7.1").readonly = true;}
if(event.target.value != "Off"){
this.getField("Score7.1").value = "";
this.getField("CheckBoxD7.1").value = "Off";
this.getField("CheckBoxD7.1").readonly = true;
this.getField("CheckBoxNA7.2").checkThisBox(0,true);
this.getField("CheckBoxNA7.2").readonly = true;}
if(event.target.value != "Off"){
this.getField("Score7.2").value = "";
this.getField("CheckBoxD7.2").value = "Off";
this.getField("CheckBoxD7.2").readonly = true;
this.getField("CheckBoxO7.2").value = "Off";
this.getField("CheckBoxO7.2").readonly = true;}
else
this.getField("CheckBoxNA7.1").checkThisBox(0,false);
this.getField("CheckBoxNA7.1").readonly = false;
if(event.target.value == "Off"){
this.getField("Score7.1").value = 3;
this.getField("CheckBoxD7.1").readonly = false;
this.getField("CheckBoxNA7.2").checkThisBox(0,false);
this.getField("CheckBoxNA7.2").readonly = false;}
if(event.target.value == "Off"){
this.getField("Score7.2").value = 4;
this.getField("CheckBoxD7.2").readonly = false;
this.getField("CheckBoxO7.2").readonly = false;}
Copy link to clipboard
Copied
Check your { } constructs.
You set readonly of this field always to false.
Copy link to clipboard
Copied
In the first part of the code you're setting the field as read-only if the check-box is checked, but later on you're setting it as not read-only if it's not not checked... Confused? So am I... I suggest you work on your code and try to improve its clarify. Combine all the statements that should happen if the field is checked into one block, and all the ones for when it's not checked to another, and don't duplicate the conditions (with different syntax each time).
Copy link to clipboard
Copied
Check your { } constructs.
You set readonly of this field always to false.
Copy link to clipboard
Copied
In the first part of the code you're setting the field as read-only if the check-box is checked, but later on you're setting it as not read-only if it's not not checked... Confused? So am I... I suggest you work on your code and try to improve its clarify. Combine all the statements that should happen if the field is checked into one block, and all the ones for when it's not checked to another, and don't duplicate the conditions (with different syntax each time).
Copy link to clipboard
Copied
With your guidance, I got what I wanted with this:
if(event.target.isBoxChecked(0)){
this.getField("CheckBoxNA7.1").checkThisBox(0,true);
this.getField("CheckBoxNA7.1").readonly = true;
this.getField("CheckBoxNA7.2").checkThisBox(0,true);
this.getField("CheckBoxNA7.2").readonly = true;
this.getField("CheckBoxD7.1").value = "Off";
this.getField("CheckBoxD7.1").readonly = true;
this.getField("CheckBoxD7.2").value = "Off";
this.getField("CheckBoxD7.2").readonly = true;
this.getField("CheckBoxO7.2").value = "Off";
this.getField("CheckBoxO7.2").readonly = true;
if(event.target.value != "Off")
this.getField("Score7.1").value = "";
if(event.target.value != "Off")
this.getField("Score7.2").value = "";}
else{
this.getField("CheckBoxNA7.1").checkThisBox(0,false);
this.getField("CheckBoxNA7.1").readonly = false;
this.getField("CheckBoxNA7.2").checkThisBox(0,false);
this.getField("CheckBoxNA7.2").readonly = false;
this.getField("CheckBoxD7.1").readonly = false;
this.getField("CheckBoxD7.2").readonly = false;
this.getField("CheckBoxO7.2").readonly = false;
if(event.target.value == "Off")
this.getField("Score7.1").value = 3;
if(event.target.value == "Off")
this.getField("Score7.2").value = 4;}
Thank you very much
Copy link to clipboard
Copied
Better, but not quite there yet... This is the only if statement you should have:
if (event.target.isBoxChecked(0)){
// put all the statements to execute if the check-box is ticked here
} else {
// put all the statements to execute if the check-box is NOT ticked here
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more