Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

fill combobox based on value other combobox

Avatar

Level 5

Hi All.

In my LiveCycle Designer form would like to add two ComboBox and one TextBox1. First ComboBox will have list of devices (PC, Printer, Other). Second ComboBox will have list of models of device. For instance, in ComboBox1 selected PC then ComboBox2 will fill by model of PC.

Let say, if ComboBox1 selected PC so ComboBox2 will have GX300, GX400, GX500.

If ComboBox1 selected Printer so ComboBox2 will have AA11, BB11,CC22, FF44.

If ComboBox1 selected Other so ComboBox2 is collapsed and TextBox1 will appears on same place where was ComboBox2.

If is it possible how it to do? I will appreciate for sample.

Thanks.

3 Replies

Avatar

Level 10

Hi,

Here are a couple of examples that show how to script addItems() for dropdowns:

http://assure.ly/jcTahK

http://assure.ly/gcXx03

Then there is an example that shows how you can use the presence property: http://assure.ly/h7whb8.

Niall

Avatar

Level 5

Hi Niall. Thanks for replay.

Now in my form I have subform with DeviceComboBox, ModelComboBox and ModelTextBox. And I would like when user select PC the ModelComboBox will visible and ModelTextBox invisible. If other  ModelComboBox will invisible and ModelTextBox visible. My code looks like:

var oAssemblyModel = {

                       PC: [ ["GX150"], ["GX240"]],

                       Printer: [ [" "]],

                       Scanner: [ [" "]]

                     };       

function SetModelNo()

{

   ModelNoComboBox.clearItems();

   ModelNoComboBox.rawValue = null;

  

   var aParts = oAssemblyModel[xfa.event.change];

   if(aParts && aParts.length)

   {

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

      ModelNoComboBox.addItem(aParts[i][0]);

   }

}

   

form1.#subform[0].ModelNoSubform[0].DeviceComboBox::change - (JavaScript, client)

SetModelExample.SetModelNo();

 

if(ModelNoSubform.DeviceComboBox.rawValue = "PC")

{

   ModelNoComboBox.presence = "visible";

   ModelNoTextBox.presence = "invisible";

}

else

{

   ModelNoComboBox.presence = "invisible";

   ModelNoTextBox.presence = "visible";

}

How to fix that problem?

Thanks.

Avatar

Level 10

Hi,

I can't get to Designer at the moment, but a few things.

In your script in the change event, you are using .rawValue. However at this stage the change is not committed to the object, so .rawValue will not work. You could move the script to the exit event OR of you leave it in the change event, you would need to test against xfa.event.newText, eg:

if (xfa.event.newText == "PC") {

     // your script

}

In addition please note that when testing a condition you need a double equals (as a minimum, there are other operators). See above.

Good luck,

Niall