Selectbox, need to sometimes repeat selection to work

I’m working on Streamlit app using a select box to select one value, then click button which then I have retrieving data from API. Strangely enough, sometimes I select a value, and it doesn’t appear in the box, so I need to wait a few seconds and repeat again…and sometimes again for the value to register, and then it is actually picked up when I click the Submit button. Anyone else have this type of problem?

with st.sidebar.form("input_form"):
    opp_id_name_list =  tuple([""] + list(atm_df["opp_display"]))
    opportunity_id_name = st.selectbox("Select Opportunity Id", opp_id_name_list)
        opportunityid = opportunity_id_name.split(" ")[0]
    except Exception as e:
        opportunityid = ""

    if "clicked" not in st.session_state:
        st.session_state.clicked = False

    submitted = st.form_submit_button(
        "Get Opporturnity", on_click=submit_click_button
    if submitted:
        st.session_state.submit_inputs_click_button = True
        st.session_state.chr_opportunityid = opportunityid
        st.session_state.clicked = True

There are issues with your posted code.

  • Missing atm_df
  • Undefined submit_click_button

One way that might help to find the solution to your issue is to do a search. At the top-right corner of this page, there is a very helpful button.


Hi @saxon11

Any widget interaction when placed inside the st.form will be processed only after the submit button is clicked.

If instead using a normal st.button you may be able to see the widget interaction implemented quicker.