Is it possible to nest ifs into Javascript. I can make this section of Hide/Show rows work.
//Set up my control variables
// the dropdown control
var ctrlDrawings = Runner.getControl(pageid, 'Drawings');
var ctrlReqDet = Runner.getControl(pageid, 'AttachQuestion');
//the target row to appear / disappear
var SHrow1 = document.getElementById("attachyes");
var SHrow2 = document.getElementById("answerno");
var SHrow3 = document.getElementById("answerno1");
var SHrow4 = document.getElementById("answerno2");
var SHrow5 = document.getElementById("answeryes");
//My default value on page load
SHrow1.style.display = 'none';
SHrow2.style.display = 'none';
SHrow3.style.display = 'none';
SHrow4.style.display = 'none';
//SHrow5.style.display = 'none';
//Attaching documents to request - if yes show attachemnt field.
ctrlDrawings.on('change', function(e){
if (this.getValue() == 'Yes')
{
//Yes then show
SHrow1.style.display = '';
//SHrow5.style.display = '';
}else{
//else hide row
SHrow1.style.display = 'none'; }
//SHrow5.style.display = 'none'; }
});
ctrlReqDet.on('change', function(e){
if (this.getValue() == 'No')
{
//Yes then show
SHrow2.style.display = '';
SHrow3.style.display = '';
SHrow4.style.display = '';
}else{
//else hide row
SHrow2.style.display = 'none';
SHrow3.style.display = 'none';
SHrow4.style.display = 'none'; }
});
However if I uncomment the SHrow5 items nothing works. And I tried taking this section:
ctrlReqDet.on('change', function(e){
if (this.getValue() == 'No')
{
//Yes then show
SHrow2.style.display = '';
SHrow3.style.display = '';
SHrow4.style.display = '';
}else{
//else hide row
SHrow2.style.display = 'none';
SHrow3.style.display = 'none';
SHrow4.style.display = 'none'; }
});
And inserting it into the true section of the first if and it would not work. Wondering if I'm doing something wrong or if its even possible to hide a row if the Javascript is using it later in the code.