Expand my Community achievements bar.

Javascript to check for duplicate entries in 2 pull-down lists

Avatar

Level 1

I have created an application form in Acrobat 8 Professional, using LiveCycle and would like to compare selections in 2 drop-down lists so that the same option is not selected twice. I think this is something that could be done with javascript, but my experience with scripting is limited to typing the word scripting. Will someone please provide step-by-step instructions for a newbie? Thanks!

1 Reply

Avatar

Former Community Member

The attached sample compares the selected value from two drop-down lists.

// form1.page1.subform1.dd1::exit - (JavaScript, client)

if (!(form1.page1.subform1.dd1.isNull)) {

  var stooge = form1.page1.subform1.dd1.rawValue;

  stooge = stooge.toLowerCase();

  if (!(form1.page1.subform1.dd2.isNull)) {

    var stooge_ = form1.page1.subform1.dd2.rawValue;

    stooge_ = stooge_.toLowerCase();

    if (stooge == stooge_) {

      xfa.host.messageBox("You have picked the same Stooge from each list.");

    }

  }

}

// form1.page1.subform1.dd2::exit - (JavaScript, client)

if (!(form1.page1.subform1.dd2.isNull)) {

  var stooge = form1.page1.subform1.dd2.rawValue;

  stooge = stooge.toLowerCase();

  if (!(form1.page1.subform1.dd1.isNull)) {

    var stooge_ = form1.page1.subform1.dd1.rawValue;

    stooge_ = stooge_.toLowerCase();

    if (stooge == stooge_) {

      xfa.host.messageBox("You have picked the same Stooge from each list.");

    }

  }

}

I am multitasking so beware.

Steve