Hello,
I would like to update options in the selectbox using an add or remove button. The problem in the following code is options are not updated until you re-render it by changing choice in the selectbox or hitting a button once again. Is it possible to update the options automatically after modifying the options? Thanks.
Here are codes.
choices = [“A”, “B”, “C”]
if ‘choices’ not in st.session_state:
st.session_state[‘choices’] = choices
choices = st.session_state[‘choices’]
selected = st.selectbox(“Select an object”, choices)
if ‘number’ not in st.session_state:
st.session_state[‘number’] = 0
st.write(f"You selected {selected}")
if st.button(‘add’):
st.session_state[‘choices’] = choices + list(f’‘’{st.session_state[‘number’]}‘’')
st.session_state[‘number’] +=1