franasa
September 27, 2022, 6:18pm
#1
Is there a way to have this behavior also in st.form?
I’d condition a st.text_input to one of the possible options in the st.selectbox, like this:
[selectbox]
import streamlit as st
# Create selectbox
options = [f"Option #{i}" for i in range(3)] + ["Another option..."]
selection = st.selectbox("Select option", options=options)
# Create text input for user entry
if selection == "Another option...":
otherOption = st.text_input("Enter your other option...")
# Just to show the selected option
if selection != "Another option...":
st.info(f…
such a feature could be especially useful for optional inputs
edsaac
September 28, 2022, 1:34am
#2
Short answer is no, because all components within the st.form
wait for the st.form_submit_button
to pass their values. But a workaround using st.empty
containers was posted in the original thread.
1 Like