HighDots Forums  

Re: IE (naturally) select-option bug, workaround?

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: IE (naturally) select-option bug, workaround? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Doug Gunnoe
 
Posts: n/a

Default Re: IE (naturally) select-option bug, workaround? - 06-30-2008 , 12:27 AM






On Jun 29, 4:41 pm, Gregor Kofler <use... (AT) gregorkofler (DOT) at> wrote:
Quote:
Refactoring my old DualSelectBox [1], I thought it would be much smarter
to get rid of the new Option() stuff, and instead just switch childNodes
between the two select elements. Something like that:

function shiftSelectedOptions(src, dest) {
var i, len, opts = [];
for(i = 0, len = src.options.length; i < len; i++) {
if (src.options[i].selected) {
opts.push(src.options[i]);
}
}
for(i = 0, len = opts.length; i < len; i++) {
opts[i].selected = false;
dest.appendChild(opts[i]);
}

}

Works as expected in all reasonable browsers, alas IE6 (and perhaps 7,
too) has issues. The childNodes get removed from the source element, and
get appended to the destination element - at least that's what this
abysmal DOM Explorer tells me. But they stay invisible - as if some sort
of "refresh" is missing.
Hi Greg. I tried your script in IE7 and Firefox, and in both cases the
nodes were removed from the 'src' element. I was a little confused by
your question above. Is this what you need to happen, or not?

When I tried it, after the childNodes were appended to the 'dest'
element, they were visible in both IE7 and Firefox in the 'dest'
element. I don't have IE6 handy at the moment.

doing, opts.push(src.options[i].cloneNode(true)) keeps the drop down
option available in the original 'src' element. But, I'm not sure the
ramifications of using cloneNode on form elements and then later
submitting the form.

Quote:
BTW: The childNodes of the select elements get cleaned, i.e. all nodes
that are not of the "OPTION" type get removed, including plain textnodes.
And I don't understand why it would do that, unless the other nodes
were also children of the option nodes.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.