2

I'm having issues with setting a default value in a dropdown menu in IE9. It seems to work on other browsers. All my searches yielded people trying to use JQuery to set that attribute. But I'm not using JQuery at all. Here's a sample:

<select id="selectType" name="selectType">
<option label="1" selected="selected">1</option>
<option label="2">2</option>
<option label="3">3</option>
</select>

I forgot to add that the problem is that it's displaying a blank field as the default instead of "1".

Modo Modo
  • 113
  • 2
  • 12
  • It should work fine. Are you sure you aren't just hitting F5 / clicking refresh and having the browser give you current form values instead of default values? – Quentin Mar 04 '13 at 22:17
  • This is not a duplicate as suggested (there is no JavaScript involved in the question). Instead, it appears to be non-reproduceable and caused by something not disclosed in the question. – Jukka K. Korpela Mar 05 '13 at 04:53

1 Answers1

2

That should work just fine, although personally I would take into account that selected is a boolean attribute and therefore its presence is all that is required:

<option label="1" selected>1</option>

That being said, I'm not sure label is a valid attribute there. I'm fairly sure they're inteded for <optgroup> tags. Try removing that attribute.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592