# Perspective Dropdown Value and Text Output

**URL:** <https://forum.inductiveautomation.com/t/perspective-dropdown-value-and-text-output/66765>\
**Category:** Maker\
**Tags:** perspective\
**Created:** [November 21, 2022, 5:35pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-value-and-text-output/66765 "2022-11-21T17:35:51Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [May 1, 2024, 9:27pm UTC](https://forum.inductiveautomation.com/t/perspective-dropdown-value-and-text-output/66765/8 "2024-05-01T21:27:55Z")

</div>

After a little search, found an example of python dataset looping, and here is the resulting, and working, code, which does, indeed, return the user's selected name:

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if currentValue and currentValue.value:
		val = currentValue.value
		if val is not None:
			dataset = self.props.options
			pyDs = system.dataset.toPyDataSet(dataset)
			for item in pyDs:
				if val in item:
					val2 = item[1]
			self.custom.selected_index = val
			self.custom.selected_label = val2

```

**EDIT:**  
I don't think I have any need for the `selected_index`, though, as this code came from another use case in another thread here:

> [@Dropdown Selected Label (Value Label)](https://forum.inductiveautomation.com/t/dropdown-selected-label-value-label/69112/6):
>
> For those looking to do the same thing, I added 3 custom props to the dropdown. selected\_value - bound directly to the value prop of the dropdown a. Use a value change script to loop through the array of options and update the index and label. selected\_index - updated from change script selected\_label - updated from change script change script: def valueChanged(self, previousValue, currentValue, origin, missedEvents): val = currentValue.value if val is not None: count = len(self.pro…

Which, I think I had a similar question back on that thread, but don't recall what I was working on then and what I did with it, lol.

---

_[View the full topic](https://forum.inductiveautomation.com/t/perspective-dropdown-value-and-text-output/66765)._
