Creating a text list of selected checkbox items

Hello, I have a series of checkboxes and I need to take the checkboxes that have been selected and turn those into a comma-separated list on the results page.

For example, if you selected three different types of food, it would show you “apple, cheese, pizza” in the text box to the right of the boxes you selected. I can store the selected state of each food in global variables but Is there a simple way to do list them in that box?

Thanks in advance for your help!

food_search.rp (65.0 KB)

If you want values collected on one page to be available on another, you have to use global variables, there’s no avoiding that.

But, there is a way to capture the selections into a single variable instead of making one for each check box: food_search.rp (85.1 KB)

In my example, I set the check boxes OnSelected event to add their text, plus a space, to a hidden text area. When you click the “Search” button, it takes the string on the hidden area, finds all the spaces and replaces them with spaces plus a comma, and adds it to the “Results” text area.

When a check box is unselected, it searches through the hidden area for it’s text (plus space) and removes them.

I put all the logic on one page (because I’m lazy) and used the hidden area just so I could see what was going on, but you can write everything to a global variable directly and have the logic to add the commas run on another page’s OnPageLoad if you want.

1 Like

Hi Huban, You are awesome! This is exactly what I had needed. I was playing around with local variables but I didn’t quire know what I was doing so your example really helped to clear that up. Thank you!

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