Hey @sf558,
Thanks for sharing your question!
- is there a way to capture all the drop list into a form and clear on submission? i tried using with st.form() but it did not allow the dependency drop list to work.
What do you mean by the drop list (maybe options
)?
- how can i clear the number input when the "Save Data " is initiated?
You can reset a st.number_input
when a button is clicked by changing the session state value associated with the st.number_input
’s key. (Shoutout to @mathcatsand for the awesome example and video in this thread).
import streamlit as st
if 'number_input' not in st.session_state:
st.session_state.number_input = 0.0
def reset_number_input():
st.session_state.number_input = 0.0
number_input = st.number_input("Number input",key='number_input')
button = st.button("Button", on_click=reset_number_input)