Expand my Community achievements bar.

Data Binding in dropdown at run time?

Avatar

Former Community Member

Hi

I have 3 dropdowns Country, State and City in my form.
when user selects a particular country, state dropdown should gets filled automatically with the states of that country and the same should happen with the city dropdown also.

Is it possible to do in adobe livecycle?

and also i would like to know whether it can happen on client side?

Thanks

Abhiram

1 Reply

Avatar

Former Community Member

Yes and yes. The attached enables the selection of a football league which populates the second drop-down of teams.

Untitled.png

Untitled1.png

The scripting requirements are not trivial, particularly when you introduce a third dependent drop-down. Consider the script object used to perform the above...

// form1.#variables[0].myScriptObject - (JavaScript, client)

var epl = "Arsenal,Chelsea,Manchester United,Tottenham";

var liga = "Barcelona,Real Madrid,Valencia,Mallorca";

var seriea = "Roma,Inter Milan,AC Milan,Sampdoria";

var eplArray = new Array();

eplArray = epl.split(",");

var ligaArray = new Array();

ligaArray = liga.split(",");

var serieaArray = new Array();

serieaArray = seriea.split(",");

function loadData(dropdownField) {

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

    switch (form1.page1.subform1.league.rawValue) {

      case "English Premier League":

        for (var i=0; i < eplArray.length; i++) {

          dropdownField.addItem(eplArray[i]);

        }

        break;

      case "Spanish Liga":

        for (var i=0; i < ligaArray.length; i++) {

          dropdownField.addItem(ligaArray[i]);

        }

        break;

      case "Italian Serie A":

        for (var i=0; i < serieaArray.length; i++) {

          dropdownField.addItem(serieaArray[i]);

        }

        break;

     default:

       break;

    }

  }

}

This can be accomplished using multi-dimensional arrays also but I find the approach above simpler.

Steve