# Dropdown functions

**URL:** <https://forum.inductiveautomation.com/t/dropdown-functions/5462>\
**Category:** Ignition\
**Created:** [November 21, 2012, 8:11pm UTC](https://forum.inductiveautomation.com/t/dropdown-functions/5462 "2012-11-21T20:11:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 21, 2012, 8:11pm UTC](https://forum.inductiveautomation.com/t/dropdown-functions/5462/1 "2012-11-21T20:11:01Z")

</div>

I have two dropdown lists, what i need to happen is when i choose an item on the first dropdown, it will populate the items i enter in the if condition in the second dropdown,

here’s my code

`if event.propertyName == "selectedLabel":
	if event.source.selectedLabel == "Dropdown1":
		event.source.parent.getComponent('Dropdown2').data("Item1")` but i’m getting the error no attribute ‘call’

what am i doing wrong?

thanks

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/7db08eeb7888f26f3f89694c52acb51b1145a67b.JPG)

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 21, 2012, 8:26pm UTC](https://forum.inductiveautomation.com/t/dropdown-functions/5462/2 "2012-11-21T20:26:15Z")

</div>

When calling getComponent(), it returns an object which exposes the (bindable) properties of a component. So when you called getComponent().data(), you got an error because there is no data() method to perform any actions, the usage for getComponent is supposed to be getComponent().propertyName.

So what exactly are you trying to do, are you copying just the selected value from dropdown1 to dropdown2, or the entire dataset?

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 21, 2012, 8:36pm UTC](https://forum.inductiveautomation.com/t/dropdown-functions/5462/3 "2012-11-21T20:36:12Z")

</div>

Oh i see, what i’m trying to do is, first is i have data on the dropdown 1, the dropdown 2 has no data what i’m trying to do is when I select an item/data in dropdown 1 it will populate data on dropdown 2.  
like for example,  
dropdown 1  
item1  
item2

when item1 is selected  
dropdown 2 will display  
test1  
test2

or when item2 is selected it will display  
test3  
test4

like this.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 21, 2012, 8:56pm UTC](https://forum.inductiveautomation.com/t/dropdown-functions/5462/4 "2012-11-21T20:56:19Z")

</div>

I believe this is what you’re looking for, this will create two specific datasets, and will copy over the proper dataset based off of item1 or item2 being selected in dropdown1:

[code]headers = [“Value”,“Label”]  
data = []  
data.append([0, “test1”])  
data.append([1, “test2”])

item1\_data = system.dataset.toDataSet(headers,data)

data = []  
data.append([0, “test3”])  
data.append([1, “test4”])

item2\_data = system.dataset.toDataSet(headers,data)

if event.propertyName == “selectedLabel”:  
if event.source.selectedLabel == “item1”:  
event.source.parent.getComponent(‘Dropdown2’).data = item1\_data  
elif event.source.selectedLabel == “item2”:  
event.source.parent.getComponent(‘Dropdown2’).data = item2\_data[/code]

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 21, 2012, 9:25pm UTC](https://forum.inductiveautomation.com/t/dropdown-functions/5462/5 "2012-11-21T21:25:11Z")

</div>

this is exactly what i’m looking for. thank you.  
last one, how do you .clear a dropdown list in ignition?

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 21, 2012, 9:32pm UTC](https://forum.inductiveautomation.com/t/dropdown-functions/5462/6 "2012-11-21T21:32:33Z")

</div>

You can just create a new dataset with an empty “data” portion:

[code]headers = [“Value”,“Label”]  
data = []

new\_data = system.dataset.toDataSet(headers,data)  
event.source.parent.getComponent(“Dropdown1”).data = new\_data[/code]

Or you can just null it out:

```auto
event.source.parent.getComponent("Dropdown1").data = None
```

If you null it out, you will have to create a dataset with headers before performing dataset functions like addRow, updateRow, etc.

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 21, 2012, 9:33pm UTC](https://forum.inductiveautomation.com/t/dropdown-functions/5462/7 "2012-11-21T21:33:39Z")

</div>

Ok got it. Thanks again! ![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:") ![:thumb_right:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/2026e28c0c425034352c1b75807edf956adc75f4.gif ":thumb\_right:")😃
