Read data from one input and use it in another input, within the same form, without submitting the form

Hi! I am new to Python and Streamlit, so this might not make sense :slight_smile: . What I would like to do is, within a form, to get data from one input field and use it in another input field.
I have the following code:

full_date = date_input('Date:', datetime.date.today(), key='data_inv_key', help=None, format="DD.MM.YYYY")
year = full_date.year
selectbox('Label', (f"the year {year} was a good one", f"the year {year} was a bad one", index=0)

Currently, when I run the app, the date_input is populated with todayโ€™s date and the options under the selectbox are showing year 2024 as expected. But if I select a different year in the date_input box, the year used by the select box does not update.

So, is it possible to read the new selected date and use it in the selectbox f string, without submitting the form?
If at all possible, I guess the solution implies using session_state but I am a newbie and couldnโ€™t crack it.
Thanks in advance!

You canโ€™t do that within a form.

I see, thanks.

Then, can the user submit the form once a date is selected in the date_input field? Something equivalent to pressing Enter while in a text_input filed?

I dont think so. AFAIK only text_input and text_area have that kind of functionality.

Perhaps related: