JesseGifford
Programmer
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:
Javascript used to select all options when "All" is chosen from the list:
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:
Code:
<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>
<%
rsMarkets.MoveNext()
Wend
If (rsMarkets.CursorType > 0) Then
rsMarkets.MoveFirst
Else
rsMarkets.Requery
End If
%>
</select>
Javascript used to select all options when "All" is chosen from the list:
Code:
<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;
}
}
}
}
//-->
</script>