Using selectbox / multiselect box unable to select a value

I am running my app in local, After submit button I want to select a value from the select box but value in not available. please find the sample code

import streamlit as st


s_d_user = st.sidebar.selectbox(
                "Select User",
                ["Sample","test","available"]
            )
dd = st.sidebar.button("Submit", type="primary")

if dd:

    l_users_name = [1,2,3,4]
    s_selected_user = st.selectbox(
                "Select User",
                l_users_name
            )
    st.write(s_selected_user)

When the app launch:

After selecting value:

Buttons aren’t stateful. Nesting widgets inside a button is almost never what you want.

Check out Button behavior and examples to see some explanations and code snippets that cover some common scenarios.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.