Skip to content

dynamic drop down acc. to context #17

@spectereye

Description

@spectereye

Hi, i want options of state below changed acc. to country user selected,
i see url below mentioned "Generate options based on time or context" - but no idea how to implement it, help please, thanks!
https://offerrall.github.io/FuncToWeb/dropdowns/#use-cases-for-dynamic-dropdowns

STATES = {
    'country1': ['state1', 'state2'],
    'country2': ['state3', 'state4'],
}

def _get_countries():
    return list(STATES)

def _get_states(country):
    return STATES[country]

def population(
        country: Literal[_get_countries],
        state: Literal[_get_states]
):
    """population of state of country"""
    return f'country={country}, state={state}'

run(population)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions