I’m trying to use st.session_state so when I update the value of a selection box the other selection box is updated with the correct values. Here’s what I’ve been trying but with no luck
col1, col2, col3, col4 = st.columns([2, 2, 1, 1]) // user selects school
school_name = col1.selectbox(
"School",
options=list(school_options.values()),
format_func=lambda x: str(x['ncaa_name']),
index=4,
key="team_school",
on_change=update_school(['ncaa_name'])
)
// players should update with the values passed from school_name
player_id = col2.selectbox("Player",
options=player_options_list,
format_func= lambda x: str(x['name']),
key="player_id",
)
update_players(st.session_state['team_school'])
def update_school(school_name):
st.session_state['team_school'] = school_name
def update_players(school_name):
# Get the player options for the selected school
player_options_list = get_player_options(school_name)