Expand my Community achievements bar.

SOLVED

Problem with a script making subform visible

Avatar

Level 7

Hello

I have a form with 5 radio buttons. Two of the radio buttons, values 3 and 5 need to make a hidden subform visible. All other values leave the subform hidden. Here is my script:

 

if (this.rawValue == '1') {

page1.deliveryInformation.flowed.presence = "hidden";
}
if (this.rawValue == '2') {

page1.deliveryInformation.flowed.presence = "hidden";
}
if (this.rawValue == '3') {

page1.deliveryInformation.flowed.presence = "visible";
}

if (this.rawValue == '4') {

page1.deliveryInformation.flowed.presence = "hidden";
}

if (this.rawValue == '5') {

page1.deliveryInformation.flowed.presence = "visible";
}

else {

page1.deliveryInformation.flowed.presence = "hidden";
}

Value 3 is not working. All other values work as expected. I've been looking at this script for over an hour and can't figure out why it isn't working. Any help would be appreciated.

Thanks,

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 10

The issue is with the last else part.

Either place the conditions in

     if(){

     }

     elseif(){

     }

     else{

     }

OR

use the switch case as below.

switch (this.rawValue)

{

case "1":

page1.deliveryInformation.flowed.presence = "hidden";

break;

case "2":

page1.deliveryInformation.flowed.presence = "hidden";

break;

case "3":

page1.deliveryInformation.flowed.presence = "visible";

break;

case "4":

page1.deliveryInformation.flowed.presence = "hidden";

break;

case "5":

page1.deliveryInformation.flowed.presence = "visible";

break;

default:

page1.deliveryInformation.flowed.presence = "hidden";

}

Thanks

Srini

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

The issue is with the last else part.

Either place the conditions in

     if(){

     }

     elseif(){

     }

     else{

     }

OR

use the switch case as below.

switch (this.rawValue)

{

case "1":

page1.deliveryInformation.flowed.presence = "hidden";

break;

case "2":

page1.deliveryInformation.flowed.presence = "hidden";

break;

case "3":

page1.deliveryInformation.flowed.presence = "visible";

break;

case "4":

page1.deliveryInformation.flowed.presence = "hidden";

break;

case "5":

page1.deliveryInformation.flowed.presence = "visible";

break;

default:

page1.deliveryInformation.flowed.presence = "hidden";

}

Thanks

Srini

Avatar

Level 7

I used the elseif and that worked. Thank you

Margaret Dawn