[Python] Flask - settings select Box HTML/css [duplicate]

Discussão em 'Python' iniciado por Stack, Março 8, 2025.

  1. Stack

    Stack Membro Participativo

    Please help me with the following issue.

    I am writing a final exam application using Python and the Flask module. In Flask, I read json data and process it into a list that is sent using return to HTML.

    In HTML, I create a select box field that accepts arguments from a variable as a drop-down list. The problem is that the list has over 200 records and after expanding it takes up the entire browser window.

    I wanted to limit the display of the list to, for example 10 records and move the next ones with a slider. However, I tried to do it in CSS, limit max-heighy etc., but it did not help. I even wrote a script in Java, but that did not solve the problem either.

    It seems that passing a value from a variable resets the settings for the height of the drop-down list. I've checked on several browsers to rule out a browser display issue. It's the same everywhere.

    Has anyone encountered such a problem? Has anyone managed to limit the size of the lists?

    Processing the data in a flask:

    @app.route('/', methods = ['GET'] )
    def index():

    station_ids = data.sort_values(by='Nazwa stacji')
    station_name = station_ids['Nazwa stacji']

    return render_template('stations.html', station_names = station_name.tolist())



    HTML code:

    <form id="stationForm">
    <select name="station" id="stationSelect">
    <option value="" selected>Wybierz stację</option>
    {% for name in station_names %}
    <option value="{{ name }}">{{ name }}</option>
    {% endfor %}
    </select>
    </form>


    and css code:

    select
    {
    max-height: 25px;
    overflow-y: auto;
    border: 1px solid #ccc;
    text-align: center;
    text-align-last: center;
    }

    Continue reading...

Compartilhe esta Página