# Python Script of DropdownList PropertyChange

**URL:** <https://forum.inductiveautomation.com/t/python-script-of-dropdownlist-propertychange/28425>\
**Category:** Ignition\
**Created:** [September 20, 2019, 8:50am UTC](https://forum.inductiveautomation.com/t/python-script-of-dropdownlist-propertychange/28425 "2019-09-20T08:50:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Min.Liao](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Min.Liao](https://forum.inductiveautomation.com/u/Min.Liao)\
**Post date:** [September 20, 2019, 8:50am UTC](https://forum.inductiveautomation.com/t/python-script-of-dropdownlist-propertychange/28425/1 "2019-09-20T08:50:45Z")

</div>

I have a requirement in my development , which needs to write a script when I selected an item. How could I write the python script? Now I used the below if condition:  
if event.propetyName == ‘componentRunning’:  
event.source.SelectedIndex = 0  
if event.propetyName == ‘selectedValue’:  
myScript  
but, it’s running when I didn’t selected an item.In other words,the script will be executed many times.  
What I need is that my script will execute a time not many times when I selected an item.

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [September 20, 2019, 11:54am UTC](https://forum.inductiveautomation.com/t/python-script-of-dropdownlist-propertychange/28425/2 "2019-09-20T11:54:24Z")

</div>

This shouldn’t fire twice unless your script is also setting the value, causing a loop. Do you have any bindings on the selectedIndex, selectedValue, or selectedStringValue, or selectedLabel?

Also consider removing your `if event.propertyName == 'componentRunning'` initialization script and just setting the noSelection properties to your desired default (0)
