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))