# Deselecting radio button

**URL:** <https://forum.inductiveautomation.com/t/deselecting-radio-button/22014>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [January 21, 2019, 10:51am UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014 "2019-01-21T10:51:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anwesha\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Anwesha\_Gupta](https://forum.inductiveautomation.com/u/Anwesha_Gupta)\
**Post date:** [January 21, 2019, 10:51am UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/1 "2019-01-21T10:51:48Z")

</div>

Hello All,

I have a screen with 3 radio button options on it-  
NG TEST 1  
NG TEST 2  
NG TEST 4  
When these are selected, they send different values to a tag.

NG TEST 1 = 2 for Bordesholm\_EFR Testing.  
NG TEST 1 = 4 for Bordesholm\_EFR Testing.  
NG TEST 1 = 0 for Bordesholm\_EFR Testing.

 ![Ignition%20Query](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/773e61620b55385faf0b8a23183358274695ad0c.png)

I need to use a confirmation dialogue box with "Are you sure" message when anyone selects any of the radio buttons.

I am using a script on 'mouse clicked' to generate the confirmation dialogue and writing to the tag if a yes is selected.

> if system.gui.confirm(u'Are you sure?', 'Confirm'):  
> SiteName = system.tag.read("[Client]SiteName").value  
> system.tag.writeToTag('SystemTags/Simulation/' + SiteName + '\_EFR\_Testing', 2)  
> else:  
> event.source.selected = 0

If the user selects 'No' on the confirmation dialogue, It does not write the value to the tag. (which is what I want).

**My question is - Along with not changing the tag value, is it possible to deselect the radio button as well? Is there any way?**

Aware that the manual says - "One radio button is selected at a time under any container"

Thanks

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 21, 2019, 11:47am UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/2 "2019-01-21T11:47:42Z")

</div>

One of the radio boxes will always be selected, that is how they work.  
If you want to be able to have none selected you will have to use Check Boxes and maintain state for all 3 when one is selected.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 21, 2019, 3:04pm UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/3 "2019-01-21T15:04:21Z")

</div>

Add a hidden radio button and default back to it.

```python
if system.gui.confirm(u'Are you sure?', 'Confirm'):
  SiteName = system.tag.read("[Client]SiteName").value
  system.tag.writeToTag(‘SystemTags/Simulation/’ + SiteName + '_EFR_Testing', 2)
else:
  event.source.parent.getComponent('Default Radio Button').selected = 0

```

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [January 21, 2019, 4:03pm UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/4 "2019-01-21T16:03:38Z")

</div>

```auto
rb1 = event.source.parent.getComponent('Radio Button1')

buttonGroup = rb1.getModel().getGroup()
buttonGroup.clearSelection()

```

---

<div class="post-metadata">

**Author:** ![Anwesha\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Anwesha\_Gupta](https://forum.inductiveautomation.com/u/Anwesha_Gupta)\
**Post date:** [January 22, 2019, 8:35am UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/5 "2019-01-22T08:35:44Z")

</div>

Hi Jordan,

The hidden radio button Idea works perfectly fine. Thanks.

---

<div class="post-metadata">

**Author:** ![Anwesha\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Anwesha\_Gupta](https://forum.inductiveautomation.com/u/Anwesha_Gupta)\
**Post date:** [January 22, 2019, 8:45am UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/6 "2019-01-22T08:45:08Z")

</div>

Hello jpark,

I also wanted to try this idea without using hidden button, But couldnt get the script working.  
My script looked like -

> if system.gui.confirm(u'Are you sure?', 'Confirm'):  
> SiteName = system.tag.read("[Client]SiteName").value  
> system.tag.writeToTag('SystemTags/Simulation/' + SiteName + '\_EFR\_Testing', 2)
> 
> else:
> 
> rb1 = event.source.selected  
> buttonGroup = rb1.getModel().getGroup()  
> buttonGroup.clearSelection()

But when I select a 'No' confirmation it comes up with an error -

> Traceback (most recent call last):
> 
> File "event:mouseClicked", line 8, in
> 
> AttributeError: 'bool' object has no attribute 'getModel'
> 
> Ignition v7.8.5 (b2016120813)  
> Java: Oracle Corporation 1.8.0\_161

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 22, 2019, 1:08pm UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/7 "2019-01-22T13:08:19Z")

</div>

Compare your `rb1=...` assignment to @jpark’s `rb1=...` assignment.

---

<div class="post-metadata">

**Author:** ![Anwesha\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Anwesha\_Gupta](https://forum.inductiveautomation.com/u/Anwesha_Gupta)\
**Post date:** [January 22, 2019, 1:33pm UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/8 "2019-01-22T13:33:52Z")

</div>

Hello @pturmel,  
I had tried it that way. But it doesn’t accept the assignment. It requests for a bound property. I many be wrong in my assumption, but i assumed that we might need to use the .selected property for this assignment.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 22, 2019, 2:16pm UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/9 "2019-01-22T14:16:07Z")

</div>

The .getModel() method applies to the radio button component itself, not to any of its properties.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 22, 2019, 2:21pm UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/10 "2019-01-22T14:21:48Z")

</div>

> [@Anwesha\_Gupta](#):
>
> It requests for a bound property.

Are you referring to when you use the property browser it won't let you select just the component, but requires you to select a property in that component? If so, just type the component path in, or select a property then delete the `.value` or `.data` or whatever property you chose.

---

<div class="post-metadata">

**Author:** ![Anwesha\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Anwesha\_Gupta](https://forum.inductiveautomation.com/u/Anwesha_Gupta)\
**Post date:** [January 22, 2019, 3:05pm UTC](https://forum.inductiveautomation.com/t/deselecting-radio-button/22014/11 "2019-01-22T15:05:50Z")

</div>

It works now on the suggestion by @jpark earlier.

@pturnel: Thanks,yes it works on the component itself. I had to get rid of the .selected option to get it working (Thanks @dkhayes117)

Thanks All.

Regards
