Hi,
In the following script, I am trying to set selection to a select
option element, that is newly created within the script. It works fine
on IE installations on Windows 2000 and some XP machines. But on some
XP machines, the selection doesn't happen and it defaults to the first
element in the options array. Has anybody come across this problem ?
Any known workarounds?
Thanks
Thomas.
===================================
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<P><INPUT id=text1 name=text1 onchange="javascript:mytesting(this);">
<SELECT id=select1 style="WIDTH: 264px" name=select1>
<OPTION selected value="testing 1">testing 1</OPTION>
<OPTION value="testing 2">testing 2</OPTION>
<OPTION value="testing 3">testing 3</OPTION>
<OPTION value="testing 4">testing 4</OPTION>
<OPTION value="testing 5">testing 5</OPTION>
</SELECT><INPUT id=button1 type=button value="delect new added"
name=button1></P>
</BODY>
</HTML>
<script language="JavaScript" >
function mytesting()
{
var fsDropDown = document.getElementById("select1");
if (fsDropDown !=null) {
var tempFS = fsDropDown.value;
//var selIdx = fsDropDown.selectedIndex;
var opt = document.createElement("OPTION");
fsDropDown.options.add(opt);
tempFS = tempFS+"*";
opt.innerText = tempFS;
opt.value = tempFS;
//opt.selected = true;
fsDropDown.options[fsDropDown.options.length-1].selected=true;
fsDropDown.selectedIndex = fsDropDown.options.length-1;
}
}
</script>