set multiple drop down list values effect to other form fields

eugzl

01-03-2018

Hi All.

I have drop-down list. And I would like to know if it possible to specify in javascript condition when multiple values from the one list will effect to box of the form. For instance, If values like 2,8,12,25,30 from drop-down box make invisible some other boxes. If it is possible. How it to do?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

eugzl

04-03-2018

I solved the problem.

var r = dropdown.editValue

var s = r.substring(r.length-6);

switch(s) {

    case '4 week':

          txt1.presence = "invisible";

          txt2.presence = "visible";

          break;

    case '3 week':

          txt1.presence = "visible";

          txt2.presence = "invisible";

          break;

    default:

          txt1.presence = "visible";

          txt2.presence = "visible";

}

Answers (10)

Answers (10)

mouslander

04-03-2018

you could do this a few ways. Each selection would trigger an individual set of options. In the sample below, based on what the user selects would change the text in field 1.

If(this.rawValue == "AAA - Week - 4"){

Field1.rawValue = "Some text 1"

}

else

if(this.rawValue == "DDD - Week 2"){

Field1.rawValue = "Some text 2"

}

Else

if(this.rawValue == "CCC - Week - 5"){

Field1.rawValue = "Some text 3"

}

I can create a basic demo for you if you provide your email address.

eugzl

02-03-2018

That is right only for one value (AAA - week - 4). And what if user will select (DDD - week - 4). My purpose create code so that ALL selected values with same (week - number) are working identically.

Thanks.

mouslander

02-03-2018

Then all you need to do is to place the command on the exit event of the dropdown list. It would be something like:

If(this.rawValue == "AAA - Week - 4"){

Field1.presence = "visible"

}

Or you could do it dynamically

If(this.rawValue == "AAA - Week - 4"){

Field1.rawValue = "some text"

}

Let me know if you need a sample.

eugzl

02-03-2018

I have drop down list that has list like:

value          text

1          AAA - week - 4

2          BBB - week - 2

3          CCC - week - 2

4          DDD - week - 4

5          EEE - week - 3

6          FFF - week - 2

And I would like when user select, for instance, text "AAA - week - 4" or "DDD - week - 4" another drop down box will invisible. The same situation when user will select values 2 or 3 or 6 the textbox becomes invisible. But actual drop down list has almost one hundred similar values.

mouslander

02-03-2018

You want a drop down list that when a selection is made from it, another drop down list will appear based on the selection? if so yes that can be done.

eugzl

02-03-2018

Hi mouslander. Thanks for replay.

I don't need multi selection. My target, if user will make selection some text included "week4" other drop-down box becomes invisible. Is possible to do that?

Thanks.

mouslander

02-03-2018

You cannot do this with a drop down as you cannot multi select from a drop down list. You can achieve this with a list box if you check the "Allow Multiple Selection" Check. You have to use something like"

if (ListBox1.rawValue == "1" + "\n" + "2") //I used the "\n" because the selection will add a return. This way I am searching

                                                                 // for the return char.

{

this.rawValue = "1, 2"

}

eugzl

01-03-2018

Hi Thom Parker. Thank for replay.

I'm using LiveCycle or AEM Designer Form application. Let me rephrase my question. I want create condition on DropDown1 box selection. In my DropDown1 box has such value:

value          text

-----------------------------------

1              AAA - week4

2              BBB - week2

3              CCC - week4

4              DDD - week3

5              EEE - week2

I would like similar like this:

If (DropDown1.value == "1", "3") {

    DropDown2.presence  = "invisible";

}

else {

    DropDown2.presence  = "visible";

}

How to specify condition with some values on one drop-down box selection. If that is possible. What is correct code?

Thanks.

Thom_Parker

01-03-2018

Yes, you'll find part of your answer in this article:

https://acrobatusers.com/tutorials/change_another_field

The article presents a technique for setting the value of other fields from a dropdown. But you can use this same technique to show/hide other fields using the "field.hidden" property.