New input item based on multiselect

I have a multi-select input object. I need to gather additional information based upon these selections.
Example 1:
If I Select an item from the multi-select input
Instantiate a Radio Button for an additional option related to the multi-select.

The follow up would be. If I have two items selected in the multi-select, I would need 2 separate radio button (with the same options), but now, I’d need to associate the radio button value with the corresponding multi-select value.

Any help on how to achieve this.

and Welcome to Snowflake

Hi @dbaOnTap

You could try this way:

  1. Loop through the list returned by st.multiselect and dynamically create radio buttons within the loop. You could set the radio buttons keys as the name of the iterated multiselect option plus a serial number (to make it unique)
  2. You may need to use session state for the widgets to remember their values post page refresh


I am unsure if I really got what you are looking for, but this is what I came up with:

In this case I have selected three items on multi-select leading to 3 separate radio buttons and the “view selection radio” shows the selection of each radio button.

1 Like

This is looks like it could be close to what I am trying to do.
Can you share what you put together for this?

Below you will find 2 examples, one with a list and another with a dictionary, at first glance the dictionary example seems to be better as the selection order from the multiselect does not impact the output order. You still can get the same from the list but would take some extra work. Anyway, let me know if that helps.

import streamlit as st

#with list
st.subheader(‘Example 1’)
m1=st.multiselect(‘multiselect’, [‘A’,‘B’,‘C’],key=‘m1’)


for i in m1:
for k in list0:
if k==i:
list1.append('group ‘+k+’ radio choice '+test_radio)


#with dictionary
st.subheader(‘Example 2’)

m2=st.multiselect(‘multiselect’, [‘A’,‘B’,‘C’],key=‘m2’)


for i in m2:
for k,v in dict1.items():
if k==i:‘group’+k,m2,key=‘testdict’+k)


This gave me exactly with I needed. Thanks!!!

1 Like