Question: today, we have made two multi-choice list boxes for a project to move each other. It is required to support browsers including FF, ie, and Safari (Apple.
Problem:
Symptom 1: When you use the objselect. appendchild (objopiton) method to add an option to the SELECT statement, the list items are displayed, but the items are blank.
Symptom 2: Use objselect. Add (objopiton) to add option, which is not supported in ff.
Key code (because it is a Japanese project, comments in Japanese can be ignored ):
Function moveselected (); vaR arrseltext = new array (); // when the configuration column is selected, the selection has been completed successfully. The selection has been completed successfully. var arrvaluetextrelation = new array (); var Index = 0; // The secondary primary Primary Secondary too many rows have been selected, and the value has been selected. Too many rows have been selected before each other has been set for (VAR I = 0; I <osourcesel. options. length; I ++) {If (osourcesel. options [I]. selected) {// specify arrselvalue [Index] = osourcesel. options [I]. value; arrseltext [Index] = osourcesel. options [I]. text; // value optional values selected when there are too many options when there are too many pending values under arrvaluetextrelation [arrselvalue [Index] = osourcesel. options [I]; index ++ ;}} // when there are too many threads, there will be too many threads, too many threads, and so on. when the primary Primary Secondary; I <arrseltext. length; I ++) {// append var ooption = document. createelement ("option"); otargetsel. appendchild (ooption) ooption. TEXT = arrseltext [I]; ooption. value = arrselvalue [I. removechild (arrvaluetextrelation [arrselvalue [I]);}
Observe the above Code lines 5-59
Symptom 1 code: ooption. Text = arrseltext [I]; ooption. value = arrselvalue [I]; otargetsel. appendchild (ooption );
The code for symptom 2 is: ooption. Text = arrseltext [I]; ooption. value = arrselvalue [I]; otargetsel. Add (ooption );
Conclusion:
Symptom 1: because IE and FF have different Dom operations, a blank list is displayed in IE, because a node or attribute value can be added to the node only after the node is obtained in IE.
FF does not have this constraint.
Symptom 2: The reason is simple. FF does not support adding subnodes by adding. IE does some special processing for ADD, so it can get the expected result.
In addition, the above three codes can run normally in safari. A good browser is as attractive as his appearance.