# Checkboxes

**URL:** <https://forum.getodk.org/t/checkboxes/1007>\
**Category:** Development\
**Created:** [December 22, 2011, 10:08am UTC](https://forum.getodk.org/t/checkboxes/1007 "2011-12-22T10:08:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thapelo\_Khumomotse](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/t/b5e925/32.png) [@Thapelo\_Khumomotse](https://forum.getodk.org/u/Thapelo_Khumomotse)\
**Post date:** [December 22, 2011, 10:08am UTC](https://forum.getodk.org/t/checkboxes/1007/1 "2011-12-22T10:08:55Z")

</div>

hi all,

i have a field with 8 checkboxes...the first is _"none"_, second is _"HIV"_,  
third is _"Cancer"_, and so on..i would want _"none"_ to be selected if  
none of the other 7 are selected; the other 7 can be selected together BUT  
NOT with the _"none" option. E_ither\* \*the \*"none" _option is by its  
self, or the others can be selected together if not one of them._ \*The  
following \*constraint \*code works for just two options but not more:

WORKING CODE: \* not(selected(., 'None') and selected(., 'HIV'))\*

CODE NOT WORKING: _not(selected(., 'None') and selected(., 'HIV') and  
selected(., 'Cancer') and ......)_

Please help.

Thank you in advance

---

<div class="post-metadata">

**Author:** ![yanokwa](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/yanokwa/32/1695_2.png) [@yanokwa](https://forum.getodk.org/u/yanokwa)\
**Post date:** [December 22, 2011, 4:40pm UTC](https://forum.getodk.org/t/checkboxes/1007/2 "2011-12-22T16:40:16Z")

</div>

you have a bug in your code. should be: none and (hiv or cancer or etc)

> **···**
>
> On Thu, Dec 22, 2011 at 02:08, Thapelo Khumomotse wrote: \> hi all, \> \> i have a field with 8 checkboxes...the first is "none", second is "HIV", \> third is "Cancer", and so on..i would want "none" to be selected if none of \> the other 7 are selected; the other 7 can be selected together BUT NOT with \> the "none" option. Either the "none" option is by its self, or the others \> can be selected together if not one of them. The following constraint code \> works for just two options but not more: \> \> WORKING CODE: not(selected(., 'None') and selected(., 'HIV')) \> \> CODE NOT WORKING: not(selected(., 'None') and selected(., 'HIV') and \> selected(., 'Cancer') and ......) \> \> Please help. \> \> Thank you in advance

---

<div class="post-metadata">

**Author:** ![Carl\_Hartung](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/carl_hartung/32/7558_2.png) [@Carl\_Hartung](https://forum.getodk.org/u/Carl_Hartung)\
**Post date:** [December 22, 2011, 5:01pm UTC](https://forum.getodk.org/t/checkboxes/1007/3 "2011-12-22T17:01:02Z")

</div>

You should be able to do the following so as to not have to type out every  
node each time, too:  
not(selected(., 'None') and count-selected(.) \> 1)

more info at: [http://opendatakit.org/help/form-design/binding/](http://opendatakit.org/help/form-design/binding/)

> **···**
>
> On Thu, Dec 22, 2011 at 8:40 AM, Yaw Anokwa wrote:
> 
> > you have a bug in your code. should be: none and (hiv or cancer or etc)
> > 
> > On Thu, Dec 22, 2011 at 02:08, Thapelo Khumomotse [thapelo.khumomotse@gmail.com](mailto:thapelo.khumomotse@gmail.com) wrote:
> > 
> > > hi all,
> > > 
> > > i have a field with 8 checkboxes...the first is "none", second is "HIV",  
> > > third is "Cancer", and so on..i would want "none" to be selected if none  
> > > of  
> > > the other 7 are selected; the other 7 can be selected together BUT NOT  
> > > with  
> > > the "none" option. Either the "none" option is by its self, or the others  
> > > can be selected together if not one of them. The following constraint  
> > > code  
> > > works for just two options but not more:
> > > 
> > > WORKING CODE: not(selected(., 'None') and selected(., 'HIV'))
> > > 
> > > CODE NOT WORKING: not(selected(., 'None') and selected(., 'HIV') and  
> > > selected(., 'Cancer') and ......)
> > > 
> > > Please help.
> > > 
> > > Thank you in advance
