When filtering the select box, I get as return all the options that contains the letters “A” + “B” in order, no matter what letters we have in the middle. So, the result is something like this:
When instead I would like to receive as return only “ABB” and “ABC”. Basically, I need the filter to treat the user input as chain and not as individual letters. Is there any way to change that behavior? I checked the documentation and the forum, but found nothing.
I shared my code at the beginning. Let’s make it an app:
import streamlit as st
values = [“ABC”, “ACB”, “ABB”, “BAB”, “CAB”]
options = st.sidebar.selectbox(“Name”, values)
When I type “AB” i get as return all the values that contains “A” and then “B”, no matter where they are placed. I need the code to give me just the values what STARTS with “AB” (only “ABC” and “ABB”)
Hi @georgi, I’m not sure if what you require is possible. st.selectbox has an on_change callback that is only triggered after the change to the selectbox is made, and not while it is being changed; hence, you would not be able to use something such as .startswith() to incrementally filter what you type in your selectbox, as you type it.
Nevertheless, let’s hope a more knowledgeable person comes along with a solution; meanwhile, you could petition Streamlit for this feature.