Stuart Taylor-Jones
Stuart Taylor-Jones

Reputation: 210

Strange Select Option Behaviour

I am building a site and am having problems with select options not showing and I am not too sure what is going on.

For example, I have this page: http://bit.ly/182gqK9

If you click on the "Choose an area..." select dropdown you will see 3 options, the third is slightly cut off for some reason (not sure why that is), but if you look in the source there is clearly 6 options...

<select id="area" name="attribute_area">
    <option value="">Choose an area...</option>
    <option value="Area 2">PO1 - PO9</option>
    <option value="Area 1">PO12 - PO17</option>
    <option value="Area 2">SO14 - SO19</option>
    <option value="Area 2">SO30</option>
    <option value="Area 1">SO31</option>
</select>

I disabled JavaScript in FF and it seems to fix the issue, but if I remove all scripts from the page, the problem persists.

I also have a similar equally strange issue on this page: http://bit.ly/1aMTMJY

With that page, if you click on the select, it shows 4 options, if you click off it and back onto it, it displays 5 options. When again there are in fact 6 options.

Upvotes: 1

Views: 96

Answers (1)

dshiga
dshiga

Reputation: 306

It looks like your JavaScript is dynamically removing options from the select. When I disable JavaScript, I see the list of 6 options shown in your question. When I enable JavaScript and inspect the HTML, this is what I see:

<select id="area" name="attribute_area">
    <option value="">Choose an area...</option>
    <option value="Area 2" class="active">PO1 - PO9</option>
    <option value="Area 2" class="active">SO14 - SO19</option>
    <option value="Area 2" class="active">SO30</option>
</select>

Do you have code somewhere that updates the list of options on the fly?

The fact that disabling JS fixes the problem means that JS must be causing the problem. You say that you still see the problem even when you remove all JS from the page. What happens if, after removing all the JS, you also disable JS in the browser?

If all the JS has truly been removed, then disabling it should have no effect. On the other hand, if disabling it still fixes the problem, then there must be JS still hanging around somewhere - perhaps because the JS is being cached.

You say that you don't have any code that is explicitly trying to update the options on the fly, but perhaps some code is doing this inadvertently or indirectly.

Upvotes: 1

Related Questions