سؤال

I am upgrading my website from IE6 to IE10.

I have a function that moves user choices from one combobox to another

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

I defined the two comboboxes as

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

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

The code to activate the move from one combobox to another is:

MoveElements(choice1_select,choice2_select);

This code works well on IE6 but not on IE10. It returns an error

SCRIPT5009: 'choice1_select' is undefined 

How do I solve this?

هل كانت مفيدة؟

المحلول

IE10 is relating to choice1_select as a variable

Replace the code to activate the move with

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

Change NAME to ID in the combobox definition

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

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

See also How do I pass an HTML element as an argument to a Javascript function?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top