Using checkboxs like option buttons

Hi folks

I’m creating a quiz app; question plus 4 possible answers. Each answer has a checkbox and only one box can be checked (like an option button). I’m trying to identify which of the 4 checkboxes has its value set to true.

I would be grateful for any help.

Robbie

1 Like

Welcome to Thunkable.

You will need to have the four check boxes as a group or a list then you create a function to loop through the list testing which one is selected.

You will also need to create another function that will update the status of the four check boxes whenever the user clicks any of them. Your function will turn the status off on all of them except the one clicked.

This can be done easier in StP but it can also be done in DnD.

Thanks Muneer

I have the checkboxes in a group and loop through them with a “for each item” block. The loop is inside a “when Any Checkbox Value Changes” block. Inside the loop I’m setting all the checkbox values to false, referencing them using the “j” object. I then set the checkbox that initiated the call to true - referencing it using the “component” object. My problem is identifying which checkbox is true.

I’m teaching a class mobile app development at a fairly low level. We made the decision to use DnD, so I have to stick to that.

1 Like

I hope this demo will help you solve the issue
https://x.thunkable.com/projectPage/6290b111693a160012911dd4

Whao!

Muneer, that’s above and beyond the call of duty and I really appreciate it.

Many thanks

Robbie

1 Like

The core of the solution is having standard naming convention for the checkboxes.

This is how the screen will look like
image

The coding part is divided in two parts

  • Part 1 is to take care of the tick whenever the user clicks on one of the checkboxes by removing the tick on the other and making the tick appear on the select one
    image

  • Part 2 is to loop through the checkboxes and report which one is ticked.
    image

this is just my opinion. i think you should stick to using radio buttons for single choices and check boxes for multiple choices. it has already been a standard accepted by default. you will only confuse your user if you present check boxes but they don’t behave the way they should…

2 Likes

As far as I know Thunkable does not provide the radio option. Of course you can use a button and shape it round to look like a radio button but it will not automatically function as a radio button. You still need a similar code to function in the way users will expect it to be,

1 Like

this demo shows an example of using radio buttons:
https://x.thunkable.com/copy/9d16caa10bd335e62b114239ee587890

2 Likes

I used to make checkboxes this same way!! Nice example

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.