quakerstate79
01-26-2007, 07:46 PM
Hey guys, the following code takes a highlighted option from a select list and moves it up or down in the list according to the argument passed. Simple enough. It works exactly as expected in Fire Fox. However, in Internet Explorer it gives me [object error](object does not support that method) at the designated lines.
Here's the code
/**********************************************************
moveUsedFields() takes the selected field moves it either
up or down depending on the argument
***********************************************************/
function moveUsedFields(updown)
{
var used_columns = document.getElementById("used_column_names");
var si = 0;
try{si = used_columns.options.selectedIndex;}catch(e){si = null;}
//alert(si);
try
{
if(used_columns.options[si] != null)
{
if(updown == "up" && si>0)
{
var temp = used_columns.options[si-1];
var temp2 = used_columns.options[si];
used_columns.options[si-1] = temp2;///****this is the problem line******//
used_columns.options.add(temp,si);
used_columns.options.selectedIndex = si-1;
}
else if(updown == "down" && used_columns.options[si+1] != null)
{
var temp = used_columns.options[si+1];
var temp2 = used_columns.options[si];
used_columns.options[si+1] = temp2;
used_columns.options.add(temp,si);
used_columns.options.selectedIndex = si+1;
}
}
}catch(e){}
}
I have tried to see if the contents of used_columns.options[si-1].value or temp2.value are valid, and they are the correct values. I'm kinda stumped here. I was hoping that someone that knows more details about how Internet explorer would interpret this script could clue me in. Failing that, does anyone know a website that i could read more about the methods that Internet Explorer does support for the select.option object?
Thanks for your time reading this,
-Q
Here's the code
/**********************************************************
moveUsedFields() takes the selected field moves it either
up or down depending on the argument
***********************************************************/
function moveUsedFields(updown)
{
var used_columns = document.getElementById("used_column_names");
var si = 0;
try{si = used_columns.options.selectedIndex;}catch(e){si = null;}
//alert(si);
try
{
if(used_columns.options[si] != null)
{
if(updown == "up" && si>0)
{
var temp = used_columns.options[si-1];
var temp2 = used_columns.options[si];
used_columns.options[si-1] = temp2;///****this is the problem line******//
used_columns.options.add(temp,si);
used_columns.options.selectedIndex = si-1;
}
else if(updown == "down" && used_columns.options[si+1] != null)
{
var temp = used_columns.options[si+1];
var temp2 = used_columns.options[si];
used_columns.options[si+1] = temp2;
used_columns.options.add(temp,si);
used_columns.options.selectedIndex = si+1;
}
}
}catch(e){}
}
I have tried to see if the contents of used_columns.options[si-1].value or temp2.value are valid, and they are the correct values. I'm kinda stumped here. I was hoping that someone that knows more details about how Internet explorer would interpret this script could clue me in. Failing that, does anyone know a website that i could read more about the methods that Internet Explorer does support for the select.option object?
Thanks for your time reading this,
-Q