Expand my Community achievements bar.

SOLVED

How to create link between two drop down lists

Avatar

Level 4

Hi all,

I ve created a form in which there are two drop down lists.

Let's one drop down list contains three items A,B,C

and another drop down contains three items Apple,Banana and Cherry.

So,my query is how to create a relation between these two dropdown lists,so that if I will select 'A' from the 1st drop down list, Apple will be selected automatically from the 2nd drop down list.

Thanks,

Debadas

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi Debadas,

Niall's solution is great. You can also use a hidden field to update the second dropdown list value.

Script for the change event of first dropdown.

var select = xfa.event.change;
var Items = List1.resolveNode("#items[0]").nodes;
for (var i = 0;i<Items.length;i++) // This can be used to track the index.
    {
        if(select == Items.item(i).value)
            {
                break;
            }    
      }  

if(List1.length > 1)

{

       var Items_List2 = SecondDropdownlist.resolveNode("#items[0]").nodes;
         HiddenTextField.rawValue = Items_List2.item(i).value;
        SecondDropdownlist.rawValue = HiddenTextField.rawValue;

}

Thanks,

Bibhu.

View solution in original post

4 Replies

Avatar

Level 10

Hi Debadas,

There is an example here, using the display and bound values of the dropdowns: http://assure.ly/fYCuQ2.

Hope that helps,

Niall

Avatar

Correct answer by
Level 9

Hi Debadas,

Niall's solution is great. You can also use a hidden field to update the second dropdown list value.

Script for the change event of first dropdown.

var select = xfa.event.change;
var Items = List1.resolveNode("#items[0]").nodes;
for (var i = 0;i<Items.length;i++) // This can be used to track the index.
    {
        if(select == Items.item(i).value)
            {
                break;
            }    
      }  

if(List1.length > 1)

{

       var Items_List2 = SecondDropdownlist.resolveNode("#items[0]").nodes;
         HiddenTextField.rawValue = Items_List2.item(i).value;
        SecondDropdownlist.rawValue = HiddenTextField.rawValue;

}

Thanks,

Bibhu.

Avatar

Level 4

Thanks for your helpful answar..

Debadas

Avatar

Level 4

Thanks for your useful reply...

Debadas