cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

How do I OnCheck, UnCheck another checkbox?

Just started and have a form to make with a lot of questions that contain 3 checkboxes each.

 

As the user can only select one of the boxes for each question and the forms text generated is decided by which boxes they ticked, how can I make it so the ticking of one box immediately unticks the other 2 in that question sector so the user doesn't have to tick and then untick it to tick another or forgets to which messes up the form?

 

I tried editting the OnCheck part of "checkbox a" to say "checkbox b".Value = false but that didn't work. I also tried editing the reset part to be if("checkbox x".Value = true, true) so that it reset if another was ticked, which worked until I did it for all 3 of them and I got an error saying you can't refer to a value dependant on your value. 

 

Anyone know how I could achieve this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: How do I OnCheck, UnCheck another checkbox?

Hi

 

I hope I understand what you want:

 

Create 3 CheckBox, with Survey Questions. set:

- each CheckBox.Default with a context variable

- each CheckBox.OnCheck = UpdateContext({....}); UpdateContext({...}) in PAIR (it is a must).

 

Look at my example as attached (screenshot), and it will definitely work.

 

Screenshot (498).png

 

 

 

In fact, if you are OK, why not use ListBox which allow SelectMultiple = False and you can get it done more easily.

 

Hope this helps.

 

Have a nice day.

hpkeong

View solution in original post

6 REPLIES 6
Highlighted
Community Champion
Community Champion

Re: How do I OnCheck, UnCheck another checkbox?

Hi

 

I hope I understand what you want:

 

Create 3 CheckBox, with Survey Questions. set:

- each CheckBox.Default with a context variable

- each CheckBox.OnCheck = UpdateContext({....}); UpdateContext({...}) in PAIR (it is a must).

 

Look at my example as attached (screenshot), and it will definitely work.

 

Screenshot (498).png

 

 

 

In fact, if you are OK, why not use ListBox which allow SelectMultiple = False and you can get it done more easily.

 

Hope this helps.

 

Have a nice day.

hpkeong

View solution in original post

Highlighted
Frequent Visitor

Re: How do I OnCheck, UnCheck another checkbox?

How would I do this if all checkboxes were in  a gallery? How would I reference another checkbox in a gallery?

Highlighted
Super User
Super User

Re: How do I OnCheck, UnCheck another checkbox?

Did you figure out the Gallery piece? I'm having a similar issue: 

 

Scenario: 

  • "SelectAll" Checkbox outside Gallery
  • Checkbox1 placed in Gallery
  • Checkbox1 OnCheck property set to ClearCollect(selectedItems, ThisItem)
  • Checkbox1 Default property set to selectAll_Checkbox.Value
  • Checking Checkbox1 adds it to the selectedItems Gallery, no problem.
  • Checking selectAll_Checkbox puts a check in all the Checkboxes in the Gallery, but they are not added to the selectedItems Gallery. 

Thoughts on this one?

Highlighted
Helper I
Helper I

Re: How do I OnCheck, UnCheck another checkbox?

Checkbox 1 is xval1, checkbox 2 xval2, checkbox 3 xval3. The picture shows all as xval1. Everything else is correct, thank you for your example.

Highlighted
Frequent Visitor

Re: How do I OnCheck, UnCheck another checkbox?

Hello,

 

I know it's almost an year late to repond to this question(Related to post) but maybe this will help others coming across your post. 

For the scenario that you have a Checkbox outside of a Gallery lets call it "Select All", and you want to use it to select all items from the Gallery that has a Checkbox placed in called "Checkbox1" ( *and add them to a colection called "SelectItems") :

 

For the Gallery in my case i have only 2 items Name and File:

-Name.Text=Label for Name in Gallery

-DisplayFileName.Text= Label for File in Gallery


Set up as it follows:

1.SelectAll Checkbox outside Gallery:

OnCheck:   ForAll(Gallery.AllItems, Collect(SelectItems, {Name: Name.Text, File: DisplayFileName.Text}))
OnUncheck: Clear(SelectItems)

 

2.Checkbox1 placed in Gallery:

OnCheck:  Collect(SelectItems, {Name: Label2.Text, File: DisplayFileName.Text})
OnUncheck: Clear(SelectItems)
Default: SelectAll.Value

To test that it collects all selected checkboxes, I created a Blank Vertical Gallery and set its Items property to : SelectItems, and add 2 labels for Name and File, and set up for each on the Text property: ThisItem.File for the File label, and ThisItem.Name for the Name label.

Hope it helps! 🙂
 

Highlighted
Helper I
Helper I

Re: How do I OnCheck, UnCheck another checkbox?

Hey All,

 

I think I have found an easier way of doing this. I have 2 checkboxes. CHK1 & CHK2.

 

CHK1.OnCheck = reset(CHK2)
CHK2.OnCheck = reset(CHK1)

 

Seems to work OK for me.

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,180)