A
armyofda12monkeys
Hello all,
When I click on a select list to choose an option, then i click on a
button which runs some code which does stuff,
then tries to unset the option in the list. In IE it doesnt work, when
it seems like it should.
Also anyone know why this problem occurs, i went through
http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerProgrammingBugs
but didnt find any bugs with .selected attribute listed.
My code is attached at end: FF unsets the select with all 3 functions
i try. IE goofs up on all but the last but i wasnt sure if the last is
the best approach.
thanks,
Ari
CODE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEST</title>
<script type="text/javascript">
function deselectList1(listID)
{
var optionsList = listID.getElementsByTagName('option');
for (i = optionsList.length - 1; i>=0; i--) //for(var i=0; i <
options.length; i++)
{
optionsList.selected = false;
}
}
function deselectList2(listID)
{
var optionsList = listID.getElementsByTagName('option');
optionsList[listID.selectedIndex].selected = false;
}
function deselectList3(listID)
{
var optionsList = listID.getElementsByTagName('option');
try
{
listID.selectedIndex = -666;
}catch (e)
{
//alert('length'+ optionsList.length)
for (i = optionsList.length - 1; i>=0; i--) //for(var i=0; i <
options.length; i++)
{
optionsList.selected = false;
}
}
}
</script>
</head>
<body>
<select size="5" name="test" id="test">
<option>AAAA</option>
<option>BBBB</option>
<option>CCCC</option>
</select>
<input name="btn" type="button" value="unselect list"
onclick="deselectList1(document.getElementById('test'));" />
</body>
</html>
When I click on a select list to choose an option, then i click on a
button which runs some code which does stuff,
then tries to unset the option in the list. In IE it doesnt work, when
it seems like it should.
Also anyone know why this problem occurs, i went through
http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerProgrammingBugs
but didnt find any bugs with .selected attribute listed.
My code is attached at end: FF unsets the select with all 3 functions
i try. IE goofs up on all but the last but i wasnt sure if the last is
the best approach.
thanks,
Ari
CODE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEST</title>
<script type="text/javascript">
function deselectList1(listID)
{
var optionsList = listID.getElementsByTagName('option');
for (i = optionsList.length - 1; i>=0; i--) //for(var i=0; i <
options.length; i++)
{
optionsList.selected = false;
}
}
function deselectList2(listID)
{
var optionsList = listID.getElementsByTagName('option');
optionsList[listID.selectedIndex].selected = false;
}
function deselectList3(listID)
{
var optionsList = listID.getElementsByTagName('option');
try
{
listID.selectedIndex = -666;
}catch (e)
{
//alert('length'+ optionsList.length)
for (i = optionsList.length - 1; i>=0; i--) //for(var i=0; i <
options.length; i++)
{
optionsList.selected = false;
}
}
}
</script>
</head>
<body>
<select size="5" name="test" id="test">
<option>AAAA</option>
<option>BBBB</option>
<option>CCCC</option>
</select>
<input name="btn" type="button" value="unselect list"
onclick="deselectList1(document.getElementById('test'));" />
</body>
</html>