# Spinner selected value

**URL:** <https://forum.inductiveautomation.com/t/spinner-selected-value/5329>\
**Category:** Ignition\
**Created:** [October 25, 2012, 2:54pm UTC](https://forum.inductiveautomation.com/t/spinner-selected-value/5329 "2012-10-25T14:54:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [October 25, 2012, 2:54pm UTC](https://forum.inductiveautomation.com/t/spinner-selected-value/5329/1 "2012-10-25T14:54:45Z")

</div>

I have the value of a regular spinner input bound to a query.  
Also, on property change of the spinner, I have an outbound update query.

I am dynamically setting my minimum value to be some number \> 2.  
However, The select query mostly will return a 0 which causes the arrow keys on my spinner to do nothing.

Is there a way to make something eg.(up arrow) make the value jump into the range of the spinner so the user doesn’t think it is broken?

I need 0s to be in the spinners that don’t have values in the database so setting ALL values of the spinners \> 2 is not a good option.

---

<div class="post-metadata">

**Author:** ![tduryee](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@tduryee](https://forum.inductiveautomation.com/u/tduryee)\
**Post date:** [October 25, 2012, 4:06pm UTC](https://forum.inductiveautomation.com/t/spinner-selected-value/5329/2 "2012-10-25T16:06:24Z")

</div>

Not sure if this is what you mean, but would this do it for you?

```auto
if event.propertyName=="intValue" and event.source.intValue>0 and event.source.intValue<2:
	event.source.intValue = 2
```

(You may want to also put an ‘if’ in the update query to avoid updating the value “1” first.)

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [October 25, 2012, 6:10pm UTC](https://forum.inductiveautomation.com/t/spinner-selected-value/5329/3 "2012-10-25T18:10:16Z")

</div>

[quote=“tduryee”]Not sure if this is what you mean, but would this do it for you?

```auto
if event.propertyName=="intValue" and event.source.intValue>0 and event.source.intValue<2:
	event.source.intValue = 2
```

[/quote]

I followed your example …I decided to turn off the poll rate of the select query and only do the update query if the new value is in the range that I want and unbound the min value and set them all to 0.  
Setting the value to a new min value in the script works for me just how i wanted except upon closer examination:

suppose I have this as my prop change script on a spinner:

`
if event.source.intValue <= 3 :
	event.source.intValue = 4`  
When I get to the lower bounds… it goes past the value every 3rd click i think… anyone know a good workaround for this?

---

<div class="post-metadata">

**Author:** ![tduryee](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@tduryee](https://forum.inductiveautomation.com/u/tduryee)\
**Post date:** [October 25, 2012, 7:16pm UTC](https://forum.inductiveautomation.com/t/spinner-selected-value/5329/4 "2012-10-25T19:16:54Z")

</div>

Strange - It sure does…  
Maybe one of the Inductive people can give you a less hacky solution, but in the meantime, this will work.

```auto
def SetTo4(spinner=event.source):
	if spinner.intValue>0 and spinner.intValue<4:
		spinner.intValue=4
system.util.invokeLater(SetTo4, 1)
```

---

<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:** [October 30, 2012, 6:03pm UTC](https://forum.inductiveautomation.com/t/spinner-selected-value/5329/5 "2012-10-30T18:03:50Z")

</div>

Another approach may be to change the “enabled” property of the spinner to false if the query returns a zero, and re-enable the property when you get a valid value from the database. This way you can keep the min/max bounds as well without trying to use a propertyChange event handler.
