Sean Davison Sean Davison - 1 month ago 7
HTML Question

Need help using an HTML select box on IE8

I used the following HTML code to create a simple drop down menu. (Actully got it from this site by doing a search).

But the issue I'm having is the submit ("Go!") button works in every other browser but IE 8-9. Even works on IE 10 on a Windos Phone. CAn somebody PLEASE tell me what needs to be changed to get it working?
Thanks.

<html>
<body>
<form name="Game Results">
<select name="ddmenu_name" id="ddmenu_name" style="width: 40% !important;">
<option value="" selected>Select Game</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=60&Itemid=82">Week 1</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=61&Itemid=82">Week 2</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=62&Itemid=82">Week 3</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=63&Itemid=82">Week 4</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=64&Itemid=82">Week 5</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=65&Itemid=82">Week 6</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=66&Itemid=82">Week 7</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=67&Itemid=82">Week 8</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=68&Itemid=82">Week 9</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=69&Itemid=82">Week 10</option>
<option value="http://thealamedapirates.org/index.php?option=com_content&view=article&id=70&Itemid=82">Las Vegas</option>
</select>
<input type="button" name="Submit" value="Go!" onClick="window.open(ddmenu_name.value,'newtab'+ddmenu_name.value)">
</form>
</body>
</html>

Answer

Being able to refer to an id directly in script was an old IE hack that is not standard, you should use document.getElementById instead.

Change:

<input type="button" name="Submit" value="Go!" onClick="window.open(ddmenu_name.value,'newtab'+ddmenu_name.value)">

To:

<input type="button" name="Submit" value="Go!" onClick="window.open(document.getElementById('ddmenu_name').value,'newtab')">

Also, IE (at least IE8) doesn't support an equal sign in a window name (this will result in a script error), so you'll have to find something safer to use - such as the index of the selected value:

<input type="button" name="Submit" value="Go!" onClick="window.open(document.getElementById('ddmenu_name').value, 'NewTab_' + document.getElementById('ddmenu_name').selectedIndex)">

I'm not sure if this is an IE thing or a standard browser thing.

Working Fiddle