Problem with <option selected>


#1

so i have the following code in flask (python web framework):

<select>
{% for printer in printers %}
    {% if printer[2] %}
    <option value="{{ printer[0] }}" selected>
    {% else %}
    <option value="{{ printer[0] }}">
    {% endif %}
    {{ printer[1] }}
    </option>
{% endfor %}
</select>

which generate a select with options:

In the image, you can see on the left that option 1 is selected (the default), on the right you can see that option3 should have been selected (using FF inspector)

however, in firefox option 1 is selected by default, while this should be option 3

in chromium option 3 is default selected option, as it should be. is there something i can do make it also work for firefox? I checked MDN (mdn - select), but according to MDN i did it right..... so i checked w3 - option, which also told me i did it right? Did i miss something?

If i run the code from the MDN example in jsbin, it works fine.... I am confused


#2

Maybe it can help you:



#3

good solution, i simply added autocomplete="off" to <select>, not sure if it is valid, but it works :stuck_out_tongue:


#4

I think that it's not valid because <select> doesn't have that attribute autocomplete but I'm glad that it helped to fix your problem.


#5

adding it to option also seems to be invalid (like the stackoverflow answer suggest). I need a form. Hm.. no problem, i needed to make it into a form anyway.