1

我正在将我的网站从 IE6 升级到 IE10。

我有一个功能可以将用户选择从一个组合框移动到另一个组合框

//moves options from one selection box (combo box) to another
function MoveElements(FromCombo,ToCombo)
{
    ... code ...
}

我将两个组合框定义为

<SELECT NAME="choice1_select" CLASS="Form150" size="7" MULTIPLE>
...
</SELECT>

<SELECT NAME="choice2_select" CLASS="Form150" size="7" MULTIPLE>
...
</SELECT>

激活从一个组合框移动到另一个组合框的代码是:

MoveElements(choice1_select,choice2_select);

此代码在 IE6 上运行良好,但在 IE10 上运行良好。它返回一个错误

SCRIPT5009: 'choice1_select' is undefined 

我该如何解决这个问题?

4

1 回答 1

1

IE10 与choice1_select作为变量有关

替换代码以激活移动

MoveElements(document.getElementById("choice1_select"),
    document.getElementById("choice2_select"))

在组合框定义中更改NAMEID

<SELECT ID="choice1_select" CLASS="Form150" size="7" MULTIPLE>
...
</SELECT>

<SELECT ID="choice2_select" CLASS="Form150" size="7" MULTIPLE>
...
</SELECT>

另请参阅如何将 HTML 元素作为参数传递给 Javascript 函数?

于 2013-05-02T17:10:15.157 回答