Dan,

Still no luck with that code. The only way I can make it work is by putting
an alert('...') in the change/click handler - the delay is obviously enough
that IE has updated the DOM by the time the box is closed. Without the
alert, I just get the selections before the change.

Bah!

rob.

On 4/3/07, Dan G. Switzer, II <[EMAIL PROTECTED]> wrote:


Rob,

>Thanks for that - I'm having trouble transferring the technique behind it
>though.
>Debugging with Firebug and putting breakpoints in _Field_transferTo() and
>_transferOptions() then double-clicking or using the buttons to transfer
>never breaks...
>
>I've looked through the source for those functions anyway and instead of
>using select.selectedIndex I tried checking option.selected for each
option
>element - I still have the same problem that the function is executed
>_before_ the attributes are changed in IE6. The example page that you
>pointed me to works fine though.

I think I know what might be happening. IE may not be updating the DOM
element until after the event--which would explain why in jQuery you're
not
able to get the elements via a CSS selector.

My example code actually using DOM methods to loop through the option
array--which is more efficient anyway.

So, what it should like you'll need to do is loop through the option
elements and check the selected property for each item.

Something like this:

<select id="transferFrom" />
<select id="transferTo" />

// set the onchange event
$("#transferFrom").bind(
        "onchange",
        function(){
                moveOption(this, $("#transferTo")[0]);
        }
);

// oFrom is a reference to the select element moving items from
// sTo is a reference to the select element we're moving item to
function moveOption(oFrom, oTo){
        var iLen = oFrom.length;
        for( var i=0; i < iLen; i++ ){
                if( oForm.options[i].selected ){
                        // move item
                        oTo.options[oTo.length] = new Option(
                                oForm.options[i].text,
                                oForm.options[i].value
                        );
                        // remove item
                        oFrom.options[i] = null;
                        // since you just deleted a option, redo this
array
                        //position next loop
                        i--;
                }
        }
}

I did not test the code, but I think it should work. It's at least pretty
close.

-Dan




--
Rob Desbois
Eml: [EMAIL PROTECTED]
Tel: 01452 760631
Mob: 07946 705987
"There's a whale there's a whale there's a whale fish" he cried, and the
whale was in full view.
...Then ooh welcome. Ahhh. Ooh mug welcome.

Reply via email to