Trigger "selectbox.on_change" even if the value is the same

I’ve got a selectbox and selecting a value I wish something to happen. I know there is the option to add a callback to on_change but it will only trigger if the value actually changes. How can I make sure the callback is also triggered if the selected value is the same as the one that is already selected?

Hi @BramVanroy,

Thanks for posting! Can you share a little more about the use-case? I’m having trouble imagining a scenario in which a user would select the same value that’s already selected – wouldn’t they just leave it as-is?


Think of a selectbox that gives you some examples in a form to get a user started, e.g. “boy” and “girl”. When any of these options is selected, a “name” input field changes to an example boy’s name or girl’s name respectively (through a on_change callback). However, users are able to modify that input field themselves, too.

The implication is, that this scenario is not possible:

  • user selects “girl” option → name is automatically changed to “Elizabeth” via a callback on the selectbox
  • user changes Elizabeth to Lizzie
  • user wants to change their mind, and go back to the original Elizabeth. They try to select “girl” again (which was still active) but of course that won’t trigger the callback and thus the name cannot be changed back to Elizabeth

Just to make sure I’m understanding correctly, you’re saying that they would select “girl”, the name would change to Elizabeth, they would manually change name to Lizzie, then they would want to get back to Elizabeth, so they would un-select and then reselect the selectbox in this case? That last part is where I’m confused – I don’t get how a user would try to select “girl” again if “girl” is already selected (unless they’re going to unselect and reselect it)

Selecting girl is not to indicate the gender but to get a girl example name. So they select girl, the website fills out an example name like Elizabeth. The user changes the given name. The user then wants to reset to the Elizabeth example, but then the select won’t work.

Perhaps a selectbox is not the best suited for this example, I realise that now. Perhaps a button for Girl and one for Boy makes more sense.

Hi @BramVanroy,

I think you’re right that a selectbox isn’t the ideal option for that workflow – a button would solve the issue you’re having and probably be clearer to the user.