In a st.form, I have a list of st.checkbox and one submit button. These checkboxes are associated with certain movie ids and are displayed on the page using a for loop.
After the user presses the ‘submit’ button is there a way to obtain all the movie ids the user selected? I thought about using an array and appending the entries but have no idea how to retrieve each movie id. Also is there a way to prevent the page from refreshing when the submit button is clicked as I don’t want new movie titles to appear as a result of refreshing.
Thanks!
Hey @yu1929 , according to my understanding, you don’t want to refresh the page when the button is pressed right. Correct if I’m wrong? If it is the case just maintain a session variable and update it for preventing refresh. For example:-
bt1=st.button('Submit')
if st.session_state.get('button') != True:
st.session_state['button'] = bt1
if st.session_state['button'] == True:
if rno not in keys_length:
st.warning('🚨 Roll Number Incorrect! 😱')
else:
conn=sqlite3.connect('vitap.db')
query='select name from vitap2 where roll_number = ?;'
old_name=[i[0] for i in conn.execute(query,(rno,))]
conn.commit()
conn.close()
st.success('🔑 Roll Number Correct! 🎉')
new_name=st.text_input('Enter new name')
if st.button('Update'):
st.session_state['button'] = False
st.success(updated_new_name_funcion(new_name,rno))
st.balloons()
st.write('Old Name: {}'.format(old_name[0]))
st.write('New Name: {}'.format(new_name))
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.