Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Compare two dropdownlists values with each other!!!!!!

Avatar

Level 3

Hi ,

I have two dropdown s with some values i want to compare two dropdowns values. I have java script on the click event of the button it will compare values of drodpowns. If any redundant/duplicate value found then those values need to be deleted from the second dropdown.

function dummy()

{

var dd1=xfa.resolveNode(form1.Page1.State.somExpression);       //path to first dropdown

var dd2 = xfa.resolveNode(form1.Page1.Dummy.somExpression);  //path to second dropdown

var i =0;

var j=0;

if(State.length!= 0)//State is first dropdown

{

     for (;i<dd1.length;i++)

     {

          for(;j<dd2.length;j++)

          {

               if(dd1.getDisplayItem(i)==dd2.getDisplayItem(j))

               {

                   dd2.deleteItem(j);   //deleting the value from second dropdown.

                    break;

               }

               else

                {

                    continue;

                 }

          }

     }

}

}

But this function is not working properly it is taking first value of the DD1 and comapring with all the values of DD2 and coming out of the loop .There are other values in the DD1.So for that comapring is not happening.

Please help me !!!

Thanks in advance,

Bharathi.

2 Replies

Avatar

Level 10

Hi,

You just need to re-initialise the j variable each time though the i loop.  As you have it the second time around j will already be equal to dd2.length so will skip the inner loop.

try

for(var j=0;j<dd2.length;j++)

Regards

Bruce

Avatar

Level 3

HI bruce,

Thanks .it is working..

Thanks,

bharathi..