Copy link to clipboard
Copied
Hi there,
First, I would like to say that I don't know anything about programming language (here JavaScript).
But I have read a lot about, and did found a way to make my code work.
What I need is to simplify the code that I already have.
I need to show or hide some text fields based on user selection of a combo box.
If the user select CFL90 it hides some specific fields and show others and if select CFL120 does the same, show other fields and hide others.
I am putting that code in a PDF form.
As you will see, my working way is laborious, messy and if I do some mistake it is going to be hard to find it....
I'll appreciate any help you can give-me.
This is a part of my code:
var showcampo = false;
var Tequip = this.getField("EQUIPAMENTOS").value;
if(Tequip == "CFL90") {
showcampo = true;
}
if(showcampo) {
this.getField("CFL 90 cm").display = display.visible;
this.getField("Filtro CFL 90 cm").display = display.visible;
this.getField("CFL 120 cm").display = display.hidden;
this.getField("Filtro CFL 120 cm").display = display.hidden;
this.getField("SIM NAO 2").display = display.visible;
this.getField("INSTROTSET40").display = display.visible;
this.getField("ROTSET").display = display.visible;
this.getField("ROTSET1").display = display.visible;
this.getField("39").display = display.visible;
this.getField("INSTROTSET41").display = display.visible;
this.getField("ROTMED").display = display.visible;
this.getField("ROTMED1").display = display.visible;
this.getField("40").display = display.visible;
this.getField("INSTCFL1").display = display.visible;
this.getField("CFL1").display = display.visible;
this.getField("CFL").display = display.visible;
this.getField("41").display = display.visible;
this.getField("INSTCFL2").display = display.visible;
this.getField("CFL2").display = display.visible;
this.getField("42").display = display.visible;
this.getField("INSTCFL3").display = display.visible;
this.getField("CFL3").display = display.visible;
this.getField("43").display = display.visible;
this.getField("INSTCFL4").display = display.visible;
this.getField("CFL4").display = display.visible;
this.getField("44").display = display.visible;
this.getField("INSTCFL5").display = display.visible;
this.getField("CFL5").display = display.visible;
this.getField("45").display = display.visible;
this.getField("INSTCFL6").display = display.visible;
this.getField("CFL6").display = display.visible;
this.getField("46").display = display.visible;
this.getField("INSTCFL7").display = display.visible;
this.getField("CFL7").display = display.visible;
this.getField("47").display = display.visible;
this.getField("INSTCFL8").display = display.visible;
this.getField("CFL8").display = display.visible;
this.getField("48").display = display.visible;
this.getField("INSTCFL9").display = display.visible;
this.getField("CFL9").display = display.visible;
this.getField("49").display = display.visible;
this.getField("INSTCFL10").display = display.visible;
this.getField("CFL10").display = display.visible;
this.getField("50").display = display.visible;
this.getField("INSTCFL11").display = display.visible;
this.getField("CFL11").display = display.visible;
this.getField("51").display = display.visible;
this.getField("INSTCFL12").display = display.visible;
this.getField("CFL12").display = display.visible;
this.getField("52").display = display.visible;
this.getField("INSTCFL13").display = display.visible;
this.getField("CFL13").display = display.visible;
this.getField("53").display = display.visible;
this.getField("INSTCFL14").display = display.visible;
this.getField("CFL14").display = display.visible;
this.getField("54").display = display.visible;
this.getField("INSTCFL20").display = display.visible;
this.getField("CFL20").display = display.visible;
this.getField("62").display = display.visible;
this.getField("INSTCFL21").display = display.visible;
this.getField("CFL21").display = display.visible;
this.getField("63").display = display.visible;
this.getField("CFL90").display = display.visible;
this.getField("INSTCFL15").display = display.hidden;
this.getField("CFL15").display = display.hidden;
this.getField("55").display = display.hidden;
this.getField("CFL120").display = display.hidden;
this.getField("INSTCFL16").display = display.hidden;
this.getField("CFL16").display = display.hidden;
this.getField("56").display = display.hidden;
this.getField("INSTCFL17").display = display.hidden;
this.getField("CFL17").display = display.hidden;
this.getField("57").display = display.hidden;
this.getField("INSTCFL18").display = display.hidden;
this.getField("CFL18").display = display.hidden;
this.getField("64").display = display.hidden;
this.getField("INSTCFL19").display = display.hidden;
this.getField("CFL19").display = display.hidden;
this.getField("65").display = display.hidden;
this.getField("INSTCFL22").display = display.hidden;
this.getField("CFL22").display = display.hidden;
this.getField("HOT").display = display.hidden;
this.getField("66").display = display.hidden;
}
else
if(Tequip == "CFL120") {
this.getField("CFL 90 cm").display = display.hidden;
this.getField("Filtro CFL 90 cm").display = display.hidden;
this.getField("CFL 120 cm").display = display.visible;
this.getField("Filtro CFL 120 cm").display = display.visible;
this.getField("SIM NAO 2").display = display.visible;
this.getField("INSTROTSET40").display = display.visible;
this.getField("ROTSET").display = display.visible;
this.getField("ROTSET1").display = display.visible;
this.getField("39").display = display.visible;
this.getField("INSTROTSET41").display = display.visible;
this.getField("ROTMED").display = display.visible;
this.getField("ROTMED1").display = display.visible;
this.getField("40").display = display.visible;
this.getField("INSTCFL1").display = display.visible;
this.getField("CFL1").display = display.visible;
this.getField("CFL").display = display.visible;
this.getField("41").display = display.visible;
this.getField("INSTCFL2").display = display.visible;
this.getField("CFL2").display = display.visible;
this.getField("42").display = display.visible;
this.getField("INSTCFL3").display = display.visible;
this.getField("CFL3").display = display.visible;
this.getField("43").display = display.visible;
this.getField("INSTCFL4").display = display.visible;
this.getField("CFL4").display = display.visible;
this.getField("44").display = display.visible;
this.getField("INSTCFL5").display = display.visible;
this.getField("CFL5").display = display.visible;
this.getField("45").display = display.visible;
this.getField("INSTCFL6").display = display.visible;
this.getField("CFL6").display = display.visible;
this.getField("46").display = display.visible;
this.getField("INSTCFL7").display = display.visible;
this.getField("CFL7").display = display.visible;
this.getField("47").display = display.visible;
this.getField("INSTCFL8").display = display.visible;
this.getField("CFL8").display = display.visible;
this.getField("48").display = display.visible;
this.getField("INSTCFL9").display = display.visible;
this.getField("CFL9").display = display.visible;
this.getField("49").display = display.visible;
this.getField("INSTCFL10").display = display.visible;
this.getField("CFL10").display = display.visible;
this.getField("50").display = display.visible;
this.getField("INSTCFL11").display = display.visible;
this.getField("CFL11").display = display.visible;
this.getField("51").display = display.visible;
this.getField("INSTCFL12").display = display.visible;
this.getField("CFL12").display = display.visible;
this.getField("52").display = display.visible;
this.getField("INSTCFL13").display = display.visible;
this.getField("CFL13").display = display.visible;
this.getField("53").display = display.visible;
this.getField("INSTCFL14").display = display.visible;
this.getField("CFL14").display = display.visible;
this.getField("54").display = display.visible;
this.getField("INSTCFL15").display = display.visible;
this.getField("CFL15").display = display.visible;
this.getField("55").display = display.visible;
this.getField("CFL120").display = display.visible;
this.getField("INSTCFL16").display = display.visible;
this.getField("CFL16").display = display.visible;
this.getField("56").display = display.visible;
this.getField("INSTCFL17").display = display.visible;
this.getField("CFL17").display = display.visible;
this.getField("57").display = display.visible;
this.getField("INSTCFL18").display = display.visible;
this.getField("CFL18").display = display.visible;
this.getField("64").display = display.visible;
this.getField("INSTCFL19").display = display.visible;
this.getField("CFL19").display = display.visible;
this.getField("65").display = display.visible;
this.getField("INSTCFL20").display = display.hidden;
this.getField("CFL20").display = display.hidden;
this.getField("62").display = display.hidden;
this.getField("CFL90").display = display.hidden;
this.getField("INSTCFL21").display = display.hidden;
this.getField("CFL21").display = display.hidden;
this.getField("63").display = display.hidden;
this.getField("INSTCFL22").display = display.hidden;
this.getField("CFL22").display = display.hidden;
this.getField("HOT").display = display.hidden;
this.getField("66").display = display.hidden;
}
Have something to add?