Assistance with Multiple Checkbox fields showing and hiding same layers
Hi all, hoping for some help here, as I've been working on this for many hours now, but can't seem to find a resolution. I'm fairly new to pdf forms and Javascripting, so don't have much knowledge to pull off from. I am tasked with putting a form together where depending on what checkboxes are selected, certain sections of the form will show and hide layers and form fields. I did figure this out. However, there are a couple checkboxes on the first page that overlap in the sense that they should show the same layers and fields when selected. So if one of these are selected, it should show those fields and layers, if two are selected, they should show, and so on. The problem is, if two or more of those checkboxes are selected, and one of them is deselected, all the layers in the document dissappear. To resolve this, I tried utilizing 'or' statements but can't seem to get it to work. Here is what I have so far. Thank you much for any assistance!
{
var f = this.getField("checkbox 1");
var g = this.getField("checkbox 2");
var h = this.getField("checkbox 3");
if(f || g || h.isBoxChecked(0))
{
if(layer[i].name=="S2")
{layer[i].state=true}
if(layer[i].name=="S22")
{layer[i].state=true}
if(layer[i].name=="S23")
{layer[i].state=true}
if(layer[i].name=="S24")
{layer[i].state=true}
if(layer[i].name=="n4")
{layer[i].state=false}
if(layer[i].name=="n5")
{layer[i].state=false}
if(layer[i].name=="n6")
{layer[i].state=false}
if(layer[i].name=="n7")
{layer[i].state=false}
}
else if(f || g || h.isBoxChecked(1)){
if(layer[i].name=="S2")
{layer[i].state=false}
if(layer[i].name=="S22")
{layer[i].state=false}
if(layer[i].name=="S23")
{layer[i].state=false}
if(layer[i].name=="S24")
{layer[i].state=false}
if(layer[i].name=="n4")
{layer[i].state=true}
if(layer[i].name=="n5")
{layer[i].state=true}
{layer[i].state=false}
if(layer[i].name=="n6")
{layer[i].state=true}
if(layer[i].name=="n7")
{layer[i].state=true}
}
}



