# Simple List

**URL:** <https://forum.inductiveautomation.com/t/simple-list/6088>\
**Category:** Ignition\
**Created:** [March 23, 2013, 3:45am UTC](https://forum.inductiveautomation.com/t/simple-list/6088 "2013-03-23T03:45:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rewing](https://avatars.discourse-cdn.com/v4/letter/r/b782af/32.png) [@rewing](https://forum.inductiveautomation.com/u/rewing)\
**Post date:** [March 23, 2013, 3:45am UTC](https://forum.inductiveautomation.com/t/simple-list/6088/1 "2013-03-23T03:45:22Z")

</div>

How do I return the value selected in a list.

What am i doing wrong here

event.source.parent.getComponent(‘Label’).text = event.source.data.getSelectedValues()

---

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [March 23, 2013, 11:08am UTC](https://forum.inductiveautomation.com/t/simple-list/6088/2 "2013-03-23T11:08:12Z")

</div>

If (as your example code suggests) you are wanting to display the currently selected list value in a label, you would bind the label’s text property to an expression which uses the list’s selectedIndex property to read the correct value from its data property:`if({Root Container.List.selectedIndex}>-1,
{Root Container.List.data}[{Root Container.List.selectedIndex}, 0],
"")`The if statement is to cope with nothing in the list being selected, otherwise you will get an out of bounds error.

If on the other hand you want to access the currently selected list value in a script, you would use a script like the following:`list = event.source.parent.getComponent('List')
if list.selectedIndex>-1:
	selectedValue = list.data.getValueAt(list.selectedIndex,0)
else:
	selectedValue = ""
print selectedValue`For more information on bindings look in the user manual at Scripting / Expressions / Syntax. For more information on accessing data in a script look at Scripting / Python / Python in Ignition / Working with Different Datatypes.
