Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How do I pre-select specific values from a dynamically populated dropdown list for HTML form

<form class="uploadDataForm" action="/mapping2/{{ id }}" method = "POST">

{% for fetchcol in db_col %}

    <label for="{{ fetchcol }}">{{ fetchcol }}</label>
    <select class="form-select" name="{{ fetchcol }}" id="fetchcol{{ loop.index }}" onclick="changeColumnCol{{ loop.index }}(this.value)" >

        {% for ex_col in df_list %}
            {% if ex_col == smart_mapping_dict[fetchcol] %}
                <option value="{{ ex_col }}" selected>{{ ex_col }}</option>
            {% else %}
                <option value="{{ ex_col }}">{{ ex_col }}</option>
            {% endif %}
        {% endfor %}

    </select>
    <br>
    {% endfor %}

    <div class="text-center">
        <a href="/second_page/{{ id }}" class="btn btn-danger">Discard Data Tape</a>
        <button class="btn btn-default nextBtn text-center ">Next</button>
    </div>

</form>
 
PREVIOUS NEXT
Tagged: #How #I #specific #values #dynamically #populated #dropdown #list #HTML #form
ADD COMMENT
Topic
Name
9+9 =