View Full Version : Issues with dynamic select lists in IE7

Jesse Gifford
08-21-2008, 08:19 PM
I have a select list dynamically populated by a SQL Server database.

I want to select all items in the list when a particular item is chosen. The code I've written works great in Firefox and I'm assuming other browsers as well. It just doesn't work in IE and specifically tested not working in IE7.

Any ideas on what I can do to make this work in IE7?

Here is the code I'm using:

Select List:

<select name="Literature_MarketID" class="requiredfield" size="13" id="marketList" multiple>
<option selected="selected" value="">=== Control-click to select multiple items ===</option>
While (NOT rsMarkets.EOF)
<option value="<%=(rsMarkets.Fields.Item("Markets_ID").Value)%>" id="marketOption_<%=(rsMarkets.Fields.Item("Markets_ID").Value)%>" onClick="checkAll();"><%=(rsMarkets.Fields.Item("Markets_Description").Value)%></option>
If (rsMarkets.CursorType > 0) Then
End If

Javascript used to select all options when "All" is chosen from the list:

<script language="JavaScript" type="text/JavaScript">
function checkAll()
var allMarkets = document.getElementById("marketOption_13");

if (allMarkets.selected == true)
if (document.getElementById('marketList') != null)
var o = document.getElementById('marketList');
for (var i = o.length - 1; i > 0; --i)
o.options[i].selected = true;

Arty Effem
08-22-2008, 12:53 AM
<option value="<%=(rsMarkets.Fields.Item("Markets_ID").Value)%>" id="marketOption_<%=(rsMarkets.Fields.Item("Markets_ID").Value)%>" onClick="checkAll();">
I.E. doesn't support onclick for options. Write a handler for the select's onchange event.

Jesse Gifford
08-22-2008, 08:50 PM
That did the trick. I actually received that and some additional input in another forum. Here is the link if anyone is interested:


Thanks for your help,