# Invoking another st.button

**URL:** <https://discuss.streamlit.io/t/invoking-another-st-button/33722>\
**Category:** Using Streamlit\
**Created:** [November 23, 2022, 7:59pm UTC](https://discuss.streamlit.io/t/invoking-another-st-button/33722 "2022-11-23T19:59:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mathcatsand](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mathcatsand/32/48006_2.png) [@mathcatsand](https://discuss.streamlit.io/u/mathcatsand)\
**Post date:** [November 23, 2022, 8:47pm UTC](https://discuss.streamlit.io/t/invoking-another-st-button/33722/2 "2022-11-23T20:47:48Z")

</div>

Buttons don’t have a persistent state. They will return `True` immediately after clicking them, but go back to `False` if the user interacts with anything else. So upon clicking a button within your `movie_name` function, your page will reload with `st.button('Show Recommendations')` being false and it will look like the first page load.

You can either use a checkbox so that there is some retained state, or you can use session state to keep a memory of your button clicks.

Here’s an example creating some memory for the outer button. You can do the same for more nested buttons as needed.

```auto
# Initialize some state for showing recommendations
if 'show_recommendation' not in st.session_state:
    st.session_state.show_recommendation = False

# Callback function to make sure the state changes with each button click
def change_show():
    st.session_state.show_recommendation = not st.session_state.show_recommendation

# Independent button, with attached callback function
st.button('Show Recommendations', on_click=change_show)

# Conditional called on the key stored in session state instead of directly on the button value
if st.session_state.show_recommendation:
    st.write('Movie recommendations showing here')
    st.button('Another button here')

```

Here’s some helpful links:

> [@After clicking a submit button, create another submit button and do something else when that button is clicked](https://discuss.streamlit.io/t/after-clicking-a-submit-button-create-another-submit-button-and-do-something-else-when-that-button-is-clicked/33425):
>
> Summary Basically, once I click on a submit button, I want to create another submit button that does something if someone clicks on the following submit button. code below if(st.button('Submit')): text\_outputs = get\_sentences\_associated\_with\_phrase(nl\_query) # this returns a list with st.form("my\_form"):#, clear\_on\_submit=True): for text\_output in text\_outputs: clicked = st.checkbox(text\_output) # this creates check boxes with what was in text\_boxes …

> [@Session State Introduction](https://discuss.streamlit.io/t/session-state-introduction/33462):
>
> I created a rough draft video showing an introduction to session state. I plan to re-record it with better audio and editing, but I wanted to get community feedback before I invested in a more polished presentation. The video is aimed toward users who have either read through documentation already, or walked through their first app creation in another basic tutorial. Many questions in the Using Streamlit forum seem to boil down to details about session state, so these are the details I was figu…

---

_[View the full topic](https://discuss.streamlit.io/t/invoking-another-st-button/33722)._
