Creating text input "text" from checked checkbox items

I am a total beginner . first time posting help, hoping this is the correct way to interact with this community :slight_smile:

I would like to generate a text output that fills in a text input box from checked boxes.

I create a checkbox list, the user ticks items that they are interested in , those items after appear into a text input box.

Can you please tell me if this is doable and what the code would look like please.
Thank you so much

Hi, welcome to Thunkable! Yes, you’re doing this right. :wink:

What you’re describing is definitely possible and not too difficult. You can use the Join block in the Text drawer to combine multiple text strings into one. Assign that block to a variable and then assign the Text Input’s Text to that variable to display the combined text.

As for check boxes, you’ll need to code it so that when the check box is changed and the value is true, you’ll refresh the combined text.

The one tricky part is that you don’t want to join the existing text… you need to construct the full text from scratch each time they make a change to a checkbox. So the process would be to set the variable to an empty string (“”) and then add any parts based on the checkboxes.

That may sound confusing since you’re new to Thunkable. Give it a go and post a screenshot of blocks you’ve tried and someone can probably steer you to the next improvement.

2 Likes

Hi, so this is what I have done . it does put the text of the checkbox in the text input 2 location but one after the other and not adding them. i’d like to be able to select breakfast, lunch and dinner and see the 3 words in text input 2 and not only one after the other. I have instructed the part one the right first and then created the group like you suggested but I am not sure this is how you meant it.
Bottom part call to ChatGPT was not able to try yet, I have to get more credits.

Posting a screenshot of your blocks is really helpful but we need to back up a moment because I still don’t fully understand how you want it to work.

Can you provide a sketch or example of the choices the user might have and what a correct result would look like? And does the user need to click a Submit button or anything like that?

Does this help clarify ?

  1. user selects the criterias from checkbox
  2. selection appears in the text input 2 box - there can be mutliple items selected they appear ideally separate by a , comma.
  3. user presses the request button
  4. request is sent to open ai with a special prompt prior to the list from text input 2 .

again thank you so much for your kind help

1 Like

Yes, that’s very helpful.

I’m just going to repost the image rotated and a little brighter (if it’s too big, I’ll re-size it later; I’m on my phone):

The algorithm I would use is:

  1. When checkbox value changes
  • If value is true, add the associated value to a list
  • If value is false, find that value in the list and delete that item from the list.
  1. Convert the list to comma-separated text (there’s a block for that) and set a label’s text to that value to display it.

I can post an example of blocks later if that’s helpful.

That would be great because I am not being successful :expressionless:

You’re close! It’s so helpful when people post screenshots of their blocks. Would you be able to share the project link with me? It’s faster if I modify your blocks than try to create them all myself.

Your [if][true] condition will always be true because it’s just checking to see if true is true. It is! You need to check if [newValue]. Because that green block will either be true or false depending on the state of the checkbox.

When you insert an item in the list, do not also convert to comma-separated. That needs to happen for the label, not for the list.

When you remove an item, it’s complicated… you need to search for the value associated with that checkbox (the Text Input’s Text) and then remove the item # that was found. Again, if I have your project link, I can provide an example.

1 Like

Hi, I am so sorry for my radio silence. here is the link to the project Thunkable . I am looking forward to understand how you text translates into those blocks :slight_smile: thank you for your help

I’ll modify it and share the new link with you.

One main problem is that you’re using the green newValue block repeatedly as the value of the checked item’s text. So if I have this:

image

Then newValue for checkbox1 is true (checked) while newValue for checkbox4 is false (unchecked). The newValue block doesn’t have any connection to the label’s text value such as “item 1” or “item 4”. It can only contain true or false which is why this doesn’t really do anything:

It’s just telling Thunkable to add “true” or “false” to the end of the list.

Here’s the modified project: Thunkable

I created blocks for the first two checkbox items. You can duplicate those for the remaining items. Just change the list item # after each get # in each case (1, 2, 3, etc.).

thank you so much. this is incredibly helpful!

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