Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Makeing subforms visible depending on what is selected from the dropdown

donn44157260
Level 5
Level 5

Good day all;

Looks like I am batting “0” today. For some reason I am not able to get a number of things to work today… Maybe I should just write this day off as a loss..;>))

Any way; I am trying, without success to get sub forms to become visible depending on what is selected from a dropdown. I have tried using “switch” (see below) but I end up getting the famous “Syntax” error.

I have also tried an “if” (see below) statement, but that did not seem to work either.

What I would like to have happen is when a user selects 1 of 2 choices 1 of 2 sub forms becomes visible.

As well, if the user has initially selected the wrong dropdown and they select now select the correct one, I would like the incorrect sub form to become invisible again.

I would appreciate any help

switch (this.rawValue)

{

    case "2":

    staffing_inter.presence = "visible";

else

staffing_inter.presence = "hidden";

    break;

}

IF statement

if(this.rawValue = 2 )

{

    staffing_inter.presence = "visible"

}

else{

staffing_inter.presence = "hidden";

}

1 Accepted Solution
Jono_Moore
Correct answer by
Level 10
Level 10

Couple of things...

Switch() statements don't use "else". You have to specify each value. But you can nest other code inside a switch() statement.

Using a dropdown you have to get the new value when the selection is made.

So (this assumes you've done "Specify Item Values" on the Binding tab for the DDL):

var newValue = this.boundItem(xfa.event.newText);

switch(newValue){

     case "1":

          //code

     break;

     case "2":

          //code

     break;

     //etc.

}

Or with your if statement:

var newValue = this.boundItem(xfa.event.newText);

if(newValue = 2){

    staffing_inter.presence = "visible"

}

else{

     staffing_inter.presence = "hidden";

}

View solution in original post

6 Replies
Jono_Moore
Correct answer by
Level 10
Level 10

Couple of things...

Switch() statements don't use "else". You have to specify each value. But you can nest other code inside a switch() statement.

Using a dropdown you have to get the new value when the selection is made.

So (this assumes you've done "Specify Item Values" on the Binding tab for the DDL):

var newValue = this.boundItem(xfa.event.newText);

switch(newValue){

     case "1":

          //code

     break;

     case "2":

          //code

     break;

     //etc.

}

Or with your if statement:

var newValue = this.boundItem(xfa.event.newText);

if(newValue = 2){

    staffing_inter.presence = "visible"

}

else{

     staffing_inter.presence = "hidden";

}

View solution in original post

Niall_O_Donovan
Level 10
Level 10

Also, the double equal sign in the test for the if statement...

donn44157260
Level 5
Level 5

Thank you Jono and Niall;

I was looking through the forum and found a post by Niall that appears to be working; I was wondering if this should be used or the one that Jono has posted...

staffing_inter.presence = "hidden";

staffing_inter.preAsence = "hidden";

// Then show the appropriate one

if (this.rawValue == "2") {

staffing_inter.presence = "visible";

}

else if (this.rawValue == "3") {

    staffing_exter.presence = "visible";

}

Jono_Moore
Level 10
Level 10

Whatever works for your needs - that's going to partially depend on your layout and what is visible/not visible at the start.

donn44157260
Level 5
Level 5

Thanks Jono;

It seems that this request is still evolving.. Go figure.. ;>))

Thanks again

Chomp