Update the value of submit button using the session state

hello all,

I was wondering if there is a way to set the value of the the submit button to True right after the user clicks on it, unless the user refreshes the page? I know it does change to true right after the user click on it automatically. However, I want to make sure it doesn’t go back to false if the user clicks on another submit button.

I think there must be a way to do so with the session button, but I don’t know how.

Thank you!

You can use session_state to store information if you need to extend the memory of buttons. I just recorded a tutorial if you want to check it out. Session State Introduction

You can add a callback function to your form submit button like this:

if 'submitted' not in st.session_state:
    st.session_state.submitted = False

def update():
    st.session_state.submitted = True

# Your Form Here
st.form_submit_button('Submit', on_click=update)

if st.session_state.submitted:
    st.write('Form submitted')

Thanks so much! I solved my problem ! :slight_smile: